[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Issue: MAP-INTO (version 2)
- To: CL-Cleanup@sail.stanford.edu
- Subject: Issue: MAP-INTO (version 2)
- From: Barry Margolin <barmar@Think.COM>
- Date: Mon, 19 Jun 89 13:19 EDT
- In-reply-to: <19890619161633.3.MOON@EUPHRATES.SCRC.Symbolics.COM>
Date: Mon, 19 Jun 89 12:16 EDT
From: David A. Moon <Moon@stony-brook.scrc.symbolics.com>
The function must take at least as many arguments as there are
sequences provided, and at least one sequence must be provided.
I suggest relaxing this, to allow zero argument sequences. The length of
the result-sequence would control the number of times the function is
called. This would permit something like
(map-into my-sequence #'(lambda () (random 1.0)))
to fill a sequence with random numbers.
This appears to be what Genera does.
The arguments result-sequence and each element of sequences can each be
either a list or a vector (one-dimensional array). Note that nil is
considered to be a sequence, of length zero. If result-sequence and
each element of sequences are not all the same length, the iteration
terminates when the shortest sequence is exhausted.
I assume that the result-sequence is included when determining the
shortest sequence. If result-sequence is a vector with a fill pointer,
or an adjustable vector, how does this affect things? Intuitively, the
following things seem reasonable:
1) The result-sequence's fill pointer could be set to the number of
elements modified (i.e. the minimum of the sequences' lengths).
2) The result-sequence should be filled as if its fill pointer were
initially 0, and each result is then VECTOR-PUSHed onto the
vector. This implies (1).
3) When minimizing the sequence lengths, (array-dimension
result-sequence 0) should be used, rather than (length result-sequence),
so that the previous value of the result sequence's fill pointer does
not cause the iteration to terminate prematurely. This also implies
that the VECTOR-PUSH will never try to go beyond the size of the vector.
In the case where no argument sequences are provided, it might be
reasonable to use (length result-sequence), but I think it would be
better to maintain consistency. Fill pointers are generally used to
indicate which elements a reader should look at, not to restrict filling
in (for instance, make-array :initial-element initializes ALL the
elements, not just up to the fill pointer).
Genera appears to use (length result-sequence) all the time.
barmar