Created
February 7, 2010 07:55
-
-
Save cesare/297299 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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