Skip to content

Instantly share code, notes, and snippets.

@omegatakuma
Created June 9, 2012 13:40
Show Gist options
  • Save omegatakuma/2901014 to your computer and use it in GitHub Desktop.
Save omegatakuma/2901014 to your computer and use it in GitHub Desktop.
position-lst.scm
(define (position key lst)
(let loop ((lst lst)(n 0)(result '()))
(cond
((null? lst) (reverse result))
((eq? key (car lst))(loop (cdr lst) (+ n 1) (cons n result)))
(else (loop (cdr lst) (+ n 1) result)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment