~brenns10/funlisp

ac351e6b73aa56cc530839fe3c0df191fb5eb737 — Stephen Brennan 3 years ago fa5b46e
Add sample script implementing a filter function
1 files changed, 10 insertions(+), 0 deletions(-)

A scripts/filter.lisp
A scripts/filter.lisp => scripts/filter.lisp +10 -0
@@ 0,0 1,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)))))