Created
September 18, 2009 15:59
-
-
Save shelling/189134 to your computer and use it in GitHub Desktop.
exam mutating parameters itself
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
| ;; SEE ALSO | |
| ;; http://stackoverflow.com/questions/1080328/append-in-scheme | |
| (define foo '(hello world)) | |
| (append! foo '(bar)) | |
| (display foo)(newline) | |
| (define my-append! | |
| (lambda (a . b) | |
| (if (null? (cdr a)) | |
| (set-cdr! a b) | |
| (my-append! (cdr a) (car b))))) | |
| (my-append! foo 'my-append) | |
| (display foo)(newline) | |
| (define push | |
| (lambda (lst . varr) | |
| (append! lst varr))) | |
| (define mypush | |
| (lambda (lst . varr) | |
| (if (null? (cdr lst)) | |
| (set-cdr! lst varr) | |
| (mypush (cdr lst) (car varr))))) | |
| (push foo 'new 'push 'way) | |
| (display foo)(newline) | |
| (mypush foo 'mypush 'way) | |
| (display foo)(newline) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment