Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
(doseq [i (interleave items1 items2)]
(println i))
do i=1, min(size(items1), size(items2))
print *,items1(i), items2(i)
end do
for i := 0; i < len(items1) || i < len(items2); i++ {
if i < len(items1) {
fmt.Println(items1[i])
}
if i < len(items2) {
fmt.Println(items2[i])
}
}
mapM_ print . concat
$ zipWith (\a b -> [a,b]) items1 items2
interweave :: [a] -> [a] -> [a] -- optional signature
interweave [] ys = ys
interweave xs [] = xs
interweave (x:xs) (y:ys) = x : y : interweave xs ys
main = mapM_ print $ interweave items1 items2
const iterator1 = items1[Symbol.iterator]()
const iterator2 = items2[Symbol.iterator]()
let result1 = iterator1.next()
let result2 = iterator2.next()
while(!(result1.done && result2.done)) {
if (!result1.done) {
console.log(result1.value)
result1 = iterator1.next()
}
if (!result2.done) {
console.log(result2.value)
result2 = iterator2.next()
}
}
const shorter = _items1.length > _items2.length ? _items2 : _items1;
const longer = _items1.length <= _items2.length ? _items2 : _items1;
shorter.map((m, i) => {
console.log(m);
console.log(longer[i]);
});
IntStream.range(0, Math.max(items1.size(), items2.size()))
.boxed()
.flatMap(idx -> Stream.of(
items1.size() > idx ? items1.get(idx) : null,
items2.size() > idx ? items2.get(idx) : null
))
.filter(Objects::nonNull)
.forEach(System.out::println);
# php 5.3+
print array_reduce( array_map( null, $items1, $items2 ), function($c,$d){return $c.($c?"\n":'').implode("\n", $d); }, "")."\n" ;
#php 5.6+
print implode("\n", array_merge( ...array_map( null, $items1, $items2 )))."\n";
for pair in zip(item1, item2): print(pair)
items1.zip(items2){|pair| puts pair}
(map (lambda (x)
(display x)
(newline))
(foldr append '()
(map list items1 items2)))
items1 with: items2 do: [:item1 :item2 |
Transcript
showln: item1;
showln: item2].
stream1 := items1 readStream.
stream2 := items2 readStream.
[stream1 atEnd ifFalse: [Transcript showln: stream1 next].
stream2 atEnd ifFalse: [Transcript showln: stream2 next]]
doWhileFalse: [stream1 atEnd or: [stream2 atEnd]].