lib/srfi/srfi-1.scm: add append-map, filter, find.

This commit is contained in:
Jan Nieuwenhuizen 2016-08-14 01:40:45 +02:00
parent a3e5461952
commit da27cf183a
1 changed files with 15 additions and 0 deletions

15
lib/srfi/srfi-1.scm Normal file
View File

@ -0,0 +1,15 @@
(define (find pred lst)
(let loop ((lst lst))
(if (null? lst) #f
(if (pred (car lst)) (car lst)
(loop (cdr lst))))))
(define (filter pred lst)
(let loop ((lst lst))
(if (null? lst) '()
(if (pred (car lst))
(cons (car lst) (loop (cdr lst)))
(loop (cdr lst))))))
(define (append-map f lst)
(apply append (map f lst)))