Created
December 13, 2010 12:52
-
-
Save gclaramunt/738959 to your computer and use it in GitHub Desktop.
Estilo "The Little Schemer"
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
(* no resuelve lo que se busca, da #t si coincide algun elemento en la misma posicion en ambas listas *) | |
(define member-of-2? | |
(lambda (a lst1 lst2) | |
(cond | |
((or (null? lst1) (null? lst2) ) #f) | |
((and (eq? a (car lst1)) (eq? a (car lst2)) ) #t) | |
( else (member-of-2? a (cdr lst1) (cdr lst2) )) | |
))) | |
(* usando member? *) | |
(define member-of-2? | |
(lambda (a lst1 lst2) | |
((and (member? a lst1) (member? a lst2) )) | |
)) |
ah... si... me equivoque :D
Tal como esta calcula si coinciden en algún elemento en la misma posición.
Voy a agregarle la opcion usando member... se me ocurre que usando continuations se puede resolver sin member,
cuando llegue a casa, voy a mirar el libro a ver que se me ocurre :)
mas largo pero parece que funciona ;-)
https://gist.github.com/739378
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mmm me pierdo algo o este codigo devolveria nil si lo llamas con (member-of-2? 1 '(0 1 2) '(1 0 2)) ???