Created
May 5, 2011 20:26
-
-
Save olsonjeffery/957856 to your computer and use it in GitHub Desktop.
little schemer stuff.. '() vs quote() in racket
This file contains hidden or 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 multirember | |
(lambda (a lat) | |
(cond | |
((null? lat) ('())) | |
((eq? (car lat) a) (multirember a (cdr lat))) | |
(else (cons (car lat) | |
(multirember a (cdr lat))))))) | |
> (multirember 'jeff '(jeff kerra jeff)) | |
procedure application: expected procedure, given: '() (no arguments) | |
=== context === | |
/Users/jeff/src/racket/ls.rkt:60:2: multirember | |
/Users/jeff/Racket v5.1/collects/racket/private/misc.rkt:85:7 |
This file contains hidden or 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 multirember | |
(lambda (a lat) | |
(cond | |
((null? lat) (quote())) | |
((eq? (car lat) a) (multirember a (cdr lat))) | |
(else (cons (car lat) | |
(multirember a (cdr lat))))))) | |
> (multirember 'jeff '(jeff kerra jeff)) | |
'(kerra) |
This file contains hidden or 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 subst2 | |
(lambda (new o1 o2 lat) | |
(cond | |
((null? lat) ('())) | |
(else (cond | |
((or (eq? (car lat) o1) (eq? (car lat) o2)) (cons new (cdr lat))) | |
(else (subst2 new o1 o2 (cdr lat)))))))) | |
> (subst 'jeff 'geoff '(geoff kerra geoff)) | |
'(jeff kerra geoff) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
so, basically:
'() == (quote ()) .. too many parens.. interestingly, there are several applications where ('()) works while it doesn't in others. mysteries within mysteries...