Sha256: 219731baaf6a9d9df94095151097663506e823b211dea8afa079f60cd022f53f
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
(defun bulk-map (arr fn) (defvar index 0 group-size fn.length ret-arr []) (while (< index arr.length) (send ret-arr push (apply fn (send arr slice index (+ index group-size)))) (incr-by index group-size)) ret-arr) (defun inject (start items fn) (defvar value start) (when (list? items) (each (item index) items (setf value (fn value item index)))) value) (defun map (items fn) (inject [] items (lambda (collector item index) (send collector push (fn item index)) collector))) (defun select (items fn) (inject [] items (lambda (collector item index) (when (fn item index) (send collector push item)) collector))) (defun detect (items fn) (defvar return-item undefined index 0 items items) (until (or (= items.length index) return-item) (when (fn (get items index) index) (setf return-item (get items index))) (incr index))) (defun reject (items fn) (defvar args [ items fn ]) (select items (thunk (not (apply fn arguments))))) (defun compact (arr) (select arr (lambda (item) (as-boolean item)))) (defun flatten (&rest items) (inject [] items (lambda (collector item) (collector.concat (if (list? item) (apply flatten item) item)))))
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sibilant-0.0.4 | js/sibilant/include/functional.sibilant |
sibilant-0.0.3 | js/sibilant/include/functional.sibilant |
sibilant-0.0.2 | js/sibilant/include/functional.sibilant |