~brenns10/funlisp

ref: 7347d0eca6d0a50799d3048c21f376277e827224 funlisp/scripts/filter.lisp -rw-r--r-- 251 bytes
7347d0ecStephen Brennan Updates for readthedocs 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
(define filter (lambda (f l)
    (if (null? l)
      '()
      (if (f (car l))
        (cons (car l) (filter f (cdr l)))
        (filter f (cdr l))))))

(define main
  (lambda (args)
    (print (filter (lambda (x) (< x 5)) '(1 2 3 4 5 6 7 8 9 10)))))