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 [xs (partition 2 list)]
(apply println xs))
for(int i = 0; i < list.length; i += 2) {
print("${list[i]}, ${list[i + 1]}");
}
write (*,'(2I8,:," ")') list
pair :: [a] -> [(a, a)]
pair [] = []
pair (x:[]) = error "List had odd length"
pair (x:y:xs) = (x, y) : pair xs
mapM_ print (pair list)
everySecond :: [a] -> [a]
everySecond [] = []
everySecond (_:[]) = []
everySecond (_:x:xs) = x : everySecond xs
everySecond' :: [a] -> [a]
everySecond' = everySecond . (undefined :)
mapM_ print (zip (everySecond list) (everySecond' list))
for (let index = 0; index < list.length; index = index + 2) {
console.log(list[index], list[index + 1])
}
for(int i = 0; i < list.length; i += 2) {
System.out.println(list[i] + ", " + list[i + 1]);
}
foreach(array_chunk($list, 2) as $x) {
echo $x[0], ' ', $x[1], PHP_EOL;
}
i := Low(L);
while (i < High(L)) do
begin
writeln(L[i],', ', L[i+1]);
Inc(i,2);
end;
for x in range(0, len(list), 2):
print(list[x], list[x + 1])
for x in zip(list[::2], list[1::2]):
print(x)
list.each_slice(2){|slice| p slice}
for pair in list.chunks(2) {
println!("({}, {})", pair[0], pair[1]);
}
for (pair <- list.grouped(2))
println(s"(${pair(0)}, ${pair(1)})")
(let print-pairs ((l list))
(if (null? l)
'()
(begin
(display (car l))
(display " ")
(display (cadr l))
(newline)
(print-pairs (cddr l)))))
list pairsDo: [:a :b |
Transcript showln: 'a: ' , a , ' b: ' , b].
Dim ItemList As New List(Of String)(New String() {"one", "one", "two", "two", "three", "three"})
For x = 0 To ItemList.Count - 1 Step 2
Console.WriteLine(ItemList(x) & vbTab & ItemList(x + 1))
Next