Skip to content

Commit

Permalink
added remove example
Browse files Browse the repository at this point in the history
  • Loading branch information
webyrd committed Feb 26, 2017
1 parent e1af57f commit c7c1661
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -106,3 +106,48 @@ Set conde1 optimization flag to true in mk/mk.scm:

;; To allow use of experimental `conde1` optimization, set this to #t.
(define enable-conde1? #t)

---------------------------------------------------------

We can use `remove` rather than `remove-foo`:

(define remove
(lambda (x ls)
(cond
[(null? ls) ,A]
[(pair? (car ls)) ,D]
[(equal? (car ls) x) ,B]
[else (cons (car ls) ,C)])))

(define remove
(lambda (x ls)
(cond
[(null? ls) ,A]
[(equal? (car ls) x) ,B]
[else (cons (car ls) ,C)])))

(remove 'foo '())
=>
'()

(remove 'foo '(a))
=>
'(a)

(remove 'foo '(foo))
=>
'()

(remove 'foo '(b foo c))
=>
'(b c)

(remove 'foo '(bar foo baz (foo) foo ((quux foo) foo)))
=>
'(bar baz (foo) ((quux foo) foo))

(remove 'foo '((d foo) foo (e (foo f foo)) foo g foo (h)))
=>
'((d) (e (f)) g (h))

---------------------------------------------------------

0 comments on commit c7c1661

Please sign in to comment.