ceylon.language.zip.ceylon Maven / Gradle / Ivy
"Given two streams, form a new stream consisting of all
[[entries|Entry]] where, for any given index in the
resulting stream, the [[key|Entry.key]] of the entry is the
element occurring at the same index in the
[[first stream|keys]], and the [[item|Entry.item]] is the
element occurring at the same index in the
[[second stream|items]]. The length of the resulting stream
is the length of the shorter of the two given streams.
Thus:
zipEntries(keys, items)[i] == keys[i] -> items[i]
for every `0<=iItem>,KeyAbsent|ItemAbsent>
zipEntries
(Iterable keys,
Iterable- items)
given Key satisfies Object
given KeyAbsent satisfies Null
given ItemAbsent satisfies Null
=> mapPairs(Entry
, keys, items);
"Given two streams, form a new stream consisting of all
pairs where, for any given index in the resulting stream,
the first element of the pair is the element occurring at
the same index in the [[first stream|firstElements]], and
the second element of the pair is the element occurring at
the same index in the [[second stream|secondElements]]. The
length of the resulting stream is the length of the shorter
of the two given streams.
Thus:
zipPairs(xs, ys)[i] == [xs[i], ys[i]]
for every `0<=i
zipPairs
(Iterable firstElements,
Iterable secondElements)
given FirstAbsent satisfies Null
given SecondAbsent satisfies Null
=> mapPairs((First first,Second second) => [first,second],
firstElements, secondElements);
"Given a stream of values, and a stream of [[tuples|Tuple]],
produce a new stream of tuples formed by prepending the
values in the [[first stream|heads]] to the tuples in the
[[second stream|tails]]. The length of the resulting stream
is the length of the shorter of the two given streams.
Thus:
zip(heads, tails)[i] == [heads[i], *tails[i]]
for every `0<=i,HeadAbsent|TailAbsent>
zip
(Iterable heads,
Iterable tails)
given Tail satisfies Element[]
given HeadAbsent satisfies Null
given TailAbsent satisfies Null
=> mapPairs(Tuple, heads, tails);
© 2015 - 2024 Weber Informatics LLC | Privacy Policy