Skip to content

Commit

Permalink
insertL
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed May 7, 2012
1 parent 3a056b2 commit d270ba3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions little.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@
(cons existing (cons new (cdr lat))))
(else
(cons (car lat) (insertR new existing (cdr lat)))))))))

; insert atom to LEFT of other atom!
(define insertL
(lambda (new existing lat)
(cond
((null? lat) '())
(else
(cond
((eq? (car lat) existing)
(cons new lat))
(else
(cons (car lat) (insertL new existing (cdr lat)))))))))

0 comments on commit d270ba3

Please sign in to comment.