2018-01-28 20:29:47 +00:00
|
|
|
(def mapnil
|
|
|
|
" (mapnil f a)
|
|
|
|
Map a function over a tuple or array and return nil."
|
|
|
|
(fn [f t]
|
|
|
|
(var i 0)
|
|
|
|
(def len (length t))
|
|
|
|
(while (< i len)
|
|
|
|
(f (get t i))
|
|
|
|
(varset! i (+ i 1)))))
|
|
|
|
|
|
|
|
(def mapt
|
|
|
|
" (mapt f t)
|
|
|
|
Map a function over a tuple or array and produce a new tuple."
|
|
|
|
(fn [f t]
|
|
|
|
(var i 0)
|
|
|
|
(def len (length t))
|
|
|
|
(def accum [])
|
|
|
|
(while (< i len)
|
|
|
|
(array-push accum (f (get t i)))
|
|
|
|
(varset! i (+ i 1)))
|
|
|
|
(apply tuple accum)))
|
|
|
|
|
|
|
|
(def mapa
|
|
|
|
" (mapa f a)
|
|
|
|
Map a function over a tuple or array and produce a new array."
|
|
|
|
(fn [f t]
|
|
|
|
(var i 0)
|
|
|
|
(def len (length t))
|
|
|
|
(def accum [])
|
|
|
|
(while (< i len)
|
|
|
|
(array-push accum (f (get t i)))
|
|
|
|
(varset! i (+ i 1)))
|
|
|
|
accum))
|
|
|
|
|