Advertisement
Stoycho_KK

Untitled

Nov 9th, 2021
2,849
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.39 KB | None | 0 0
  1. (define (get-repeated-elem elem index)
  2.     (if (= index 0) `()
  3.         (cons elem (get-repeated-elem elem (- index 1)))
  4.         )
  5.     )
  6.  
  7. (define (deep-repeat l)
  8.   (define (helper l index)
  9.     (cond ((null? l) `())
  10.           ((list? (car l)) (helper (car l) (+ 1 index)))
  11.           (append (get-repeated-elem (car l) index) (helper (cdr l) index))
  12.           )
  13.     )
  14.   (helper l 0)
  15.   )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement