Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • D

Idiom #141 Iterate in sequence over two lists

Iterate in sequence over the elements of the list items1 then items2. For each iteration print the element.

import std.range;
import std.algorithm.iteration;
import std.stdio;
chain(items1, items2).each!writeln;
;; for side effects
(doseq [x (concat items1 items2)]
   (println x))

concat concatenates two or more sequences https://clojuredocs.org/clojure.core/concat
doseq for side effects. Alternatively for to produce a new sequence https://clojuredocs.org/clojure.core/doseq
https://clojuredocs.org/clojure.core/for

New implementation...
< >
BBaz