[erlang-questions] Proposal: add lists:intersperse/2 and lists:intercalate/2
Richard A. O'Keefe
ok@REDACTED
Thu Mar 3 01:41:08 CET 2016
On 3/03/16 6:02 am, Siraaj Khandkar wrote:
> Though I prefer the name "interleave" to "intersperse", since its
> meaning is more-precise and closer to the intended behavior here.
No, interleaving requires *two* sequences. This is interleave:
interleave([], []) -> [];
interleave([X|Xs], [Y|Ys]) -> [X,Y|interleave(Xs,Ys)].
interleave, v, OED, sense 3:
"Computing and Telecommunications. To interfile (two or more
digitized signals or sequences of information) by alternating
between them; to alternate (one such signal or sequence) with
others. Also, to divide (memory, etc.) between a number of
different tasks by allocating successive segments to each in turn."
(I must admit I hadn't encountered the word 'interfile' before.)
More information about the erlang-questions
mailing list