Add filter-map.

* module/srfi/srfi-1.mes (filter-map): New function.
This commit is contained in:
Jan Nieuwenhuizen 2017-01-03 22:11:34 +01:00
parent aa82c408eb
commit 6d5cfad356

View file

@ -1,7 +1,7 @@
;;; -*-scheme-*-
;;; Mes --- Maxwell Equations of Software
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of Mes.
;;;
@ -40,6 +40,12 @@
(define (append-map f lst)
(apply append (map f lst)))
(define (filter-map f lst)
(if (null? lst) (list)
(let ((r (f (car lst))))
(if r (cons r (filter-map f (cdr lst)))
(filter-map f (cdr lst))))))
;;; nyacc requirements
(define (fold proc init lst1 . rest)