Try

    [rest (filter-odds rest]

as the last clause.

søn. 21. apr. 2019 kl. 22.19 skrev Tim Meehan <btmee...@gmail.com>:

> Forgive this naive question, I am having some trouble understanding some
> matching forms. If I wanted to filter out odd numbers like this:
>
> (filter odd? '(1 2 3 4 5)) => '(1 3 5)
>
> but I wanted to do this with a match:
> (define (filter-odds v)
>   (match v
>     [empty empty]
>     [(cons (? odd? first) rest) (cons first (filter-odds rest))]
>     [_ (filter-odds rest)]))
>
> (filter-odds '(1 2 3 4 5)) => '(1 2 3 4 5)
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to