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.

Revisions

  1. sham1 created this gist Mar 18, 2022.
    23 changes: 23 additions & 0 deletions destructuring-bind.scm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    (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))