Logo

Programming-Idioms

History of Idiom 163 > diff from v20 to v21

Edit summary for version 21 by cdo:
New Scheme implementation by user [cdo]

Version 20

2019-10-05, 00:45:14

Version 21

2020-04-28, 20:56:54

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

Code
(let print-pairs ((l list))
  (if (null? l)
      '()
      (begin
        (display (car l))
        (display " ")
        (display (cadr l))
        (newline)
        (print-pairs (cddr l)))))