alist map/filter/for-each
This commit is contained in:
parent
75224b9100
commit
b40fe9cdec
15
d-.scm
15
d-.scm
@ -15,6 +15,9 @@
|
||||
upply
|
||||
conjoin
|
||||
distinct?
|
||||
amap
|
||||
afilter
|
||||
afor-each
|
||||
generator
|
||||
macro-expand
|
||||
amb
|
||||
@ -103,6 +106,18 @@
|
||||
(and (not (any (lambda (x) (equal? (car a) x)) (cdr a)))
|
||||
(apply distinct? (cdr a)))))
|
||||
|
||||
(define (amap f l)
|
||||
"Same as (map f l) but passes car and cdr to the function"
|
||||
(map (lambda (kons) (f (car kons) (cdr cons))) l))
|
||||
|
||||
(define (afilter f l)
|
||||
"Same as (filter f l) but passes car and cdr to the function"
|
||||
(filter (lambda (kons) (f (car kons) (cdr cons))) l))
|
||||
|
||||
(define (afor-each f l)
|
||||
"Same as (for-each f l) but passes car and cdr to the function"
|
||||
(for-each (lambda (kons) (f (car kons) (cdr cons))) l))
|
||||
|
||||
;; Shamelessly ripped from https://wingolog.org/archives/2013/02/25/on-generators
|
||||
(define (make-generator f)
|
||||
(define tag (make-prompt-tag))
|
||||
|
Loading…
Reference in New Issue
Block a user