Advertisement
Guest User

BaraksAssOneScheme

a guest
Dec 28th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.65 KB | None | 0 0
  1. #lang racket
  2.  
  3. (define foo (lambda (x s)
  4.  
  5.               (if (list? s)
  6.  
  7.                   (if (< (length s) 2)
  8.                       '()
  9.  
  10.                       (if (list? (first s))
  11.                      
  12.                           (append (foo x (first s)) (foo x (rest s)))
  13.  
  14.                           (if (equal? x (first s))
  15.                               (append (list (second s)) (foo x (rest s)))
  16.                               (foo x (rest s))
  17.                               )
  18.                           )
  19.                       )
  20.  
  21.                  '()
  22.               )
  23.             )
  24. )
  25.  
  26. (foo 'y '(y (3 y 5 y y 8 9) (10 y 12 13 y 15 y) 17))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement