Skip to content

Instantly share code, notes, and snippets.

@sham1
Created March 18, 2022 16:19
Show Gist options
  • Save sham1/35aa8cb90fccd77b26db17e23df46ff3 to your computer and use it in GitHub Desktop.
Save sham1/35aa8cb90fccd77b26db17e23df46ff3 to your computer and use it in GitHub Desktop.
destructuring-bind in R7RS
(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