Advertisement
Guest User

Untitled

a guest
Mar 13th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.41 KB | None | 0 0
  1. #lang racket
  2.  
  3. (define (at-level lst n curdepth)
  4.   (cond
  5.    [(empty? lst) empty]
  6.    [(list? (first lst)) (append
  7.                          (at-level (first lst) n (+ 1 curdepth))
  8.                          (at-level (rest lst) n curdepth))]
  9.    [(= n curdepth) (cons (first lst) (at-level (rest lst) n curdepth))]
  10.    [(at-level (rest lst) n curdepth)]))
  11.  
  12. (define a '(1 2 (3 4) 5 (6 7)))
  13.  
  14. (at-level a 2 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement