22 lines
548 B
Text
22 lines
548 B
Text
;; Scheme's vector-for-each: a one-liner in TXR
|
|
;; that happily works over strings and lists.
|
|
;; We don't need "srfi-43".
|
|
(defun vector-for-each (fun . vecs)
|
|
[apply mapcar fun (range) vecs])
|
|
|
|
(defun display (obj : (stream *stdout*))
|
|
(pprint obj stream))
|
|
|
|
(defun newline (: (stream *stdout*))
|
|
(display #\newline stream))
|
|
|
|
(let ((a (vec "a" "b" "c"))
|
|
(b (vec "A" "B" "C"))
|
|
(c (vec 1 2 3)))
|
|
(vector-for-each
|
|
(lambda (current-index i1 i2 i3)
|
|
(display i1)
|
|
(display i2)
|
|
(display i3)
|
|
(newline))
|
|
a b c))
|