Logo

Programming-Idioms

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

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.

mapM_ print $ items1 ++ items2

$ is the function application operator of Haskell to eliminate annoying parentheses.

E.g., f $ g x y z == f (g x y z)
;; 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