Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.31 KB | None | 0 0
  1. (define (move item lst)
  2.   (if (null? lst)
  3.     (list item)
  4.     (if (= item 0)
  5.       (append (move (car lst) (cdr lst)) '(0))
  6.       (cons item (move (car lst) (cdr lst))))))
  7.  
  8. (define (MoveZeros lst)
  9.   (if (null? lst)
  10.     lst
  11.     (move (car lst) (cdr lst))))
  12.  
  13. (MoveZeros '(0 1 4 0 2 4 0 5 1 3 0 2 3 1 7 8))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement