Created
March 18, 2022 16:19
-
-
Save sham1/35aa8cb90fccd77b26db17e23df46ff3 to your computer and use it in GitHub Desktop.
destructuring-bind in R7RS
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
(import (scheme base) | |
(scheme write)) | |
(define-syntax destructuring-bind | |
(syntax-rules () | |
((_ (name1 names ...) var body1 bodys ...) | |
(apply | |
(lambda (name1 names ...) | |
body1 bodys ...) | |
var)))) | |
(destructuring-bind (a b c) '(1 2 3) | |
(display "a: ") | |
(display a) | |
(newline) | |
(display "b: ") | |
(display b) | |
(newline) | |
(display "c: ") | |
(display c) | |
(newline)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment