Skip to content

Instantly share code, notes, and snippets.

@cesare
Created February 7, 2010 07:55
Show Gist options
  • Save cesare/297299 to your computer and use it in GitHub Desktop.
Save cesare/297299 to your computer and use it in GitHub Desktop.
(define (remains lst key)
(cond ((null? lst) -1)
((eq? (car lst) key) (length (cdr lst)))
(else (remains (cdr lst) key))))
(define sample-list '(World is not enough))
(remains sample-list 'World) ;; => 3
(remains sample-list 'is) ;; => 2
(remains sample-list 'enough) ;; => 0
(remains sample-list 'nothing) ;; => -1
;; see also http://kaitenn.blogspot.com/2010/01/scala-list.html
;; http://d.hatena.ne.jp/yuroyoro/20100205/1265363784
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment