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
|
upply
|
||||||
conjoin
|
conjoin
|
||||||
distinct?
|
distinct?
|
||||||
|
amap
|
||||||
|
afilter
|
||||||
|
afor-each
|
||||||
generator
|
generator
|
||||||
macro-expand
|
macro-expand
|
||||||
amb
|
amb
|
||||||
@ -103,6 +106,18 @@
|
|||||||
(and (not (any (lambda (x) (equal? (car a) x)) (cdr a)))
|
(and (not (any (lambda (x) (equal? (car a) x)) (cdr a)))
|
||||||
(apply distinct? (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
|
;; Shamelessly ripped from https://wingolog.org/archives/2013/02/25/on-generators
|
||||||
(define (make-generator f)
|
(define (make-generator f)
|
||||||
(define tag (make-prompt-tag))
|
(define tag (make-prompt-tag))
|
||||||
|
4
test.scm
4
test.scm
@ -80,6 +80,10 @@
|
|||||||
(define-test "vacuous"
|
(define-test "vacuous"
|
||||||
(assert-equal #t ((conjoin) '(some donkus)))))
|
(assert-equal #t ((conjoin) '(some donkus)))))
|
||||||
|
|
||||||
|
(define-test-suite "map"
|
||||||
|
(define-test "test"
|
||||||
|
(assert-equal )))
|
||||||
|
|
||||||
(define-test-suite "generator"
|
(define-test-suite "generator"
|
||||||
(define-test "test"
|
(define-test "test"
|
||||||
(define number-generator
|
(define number-generator
|
||||||
|
Loading…
Reference in New Issue
Block a user