Advertisement
Guest User

Untitled

a guest
Jan 9th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.60 KB | None | 0 0
  1. #lang racket
  2.  
  3. (define foo (lambda (cond ls)
  4.  
  5.               (if (null? ls)
  6.  
  7.                   (list)
  8.  
  9.                   (if (list? (first ls))
  10.  
  11.                       (append (foo cond (first ls)) (foo cond (rest ls)))
  12.  
  13.                       ;else:
  14.  
  15.                       (if (cond (first ls))
  16.  
  17.                           (append (list (first ls))  (foo cond (rest ls)))
  18.  
  19.                           ;else:
  20.  
  21.                           (foo cond (rest ls))
  22.  
  23.                           )
  24.                       )
  25.               )
  26.         )
  27. )
  28.  
  29. (foo number? '(1 b (3 c 4) 3 f (3 j (4 4 (5 l))) 5 4 h 8))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement