[CM] Let with list destructuring
Christos Vagias
chris.actondev at gmail.com
Thu Sep 10 03:30:02 PDT 2020
Hi all,
Wanted to share with you a macro I wrote about let (and let*) with
list destructuring. Something similar to the destructuring-bind as seen
in stuff.scm
I missed this functionality from clojure.
Example usage:
;; letd: mnemonic: let-destructure
(letd ((a 1)
(b 2)
((c d) (list (+ 1 2) 4)))
(list a b c d ))
;; => (1 2 3 4)
(letd* ((a 1)
(b 2)
((c d) (list (+ 1 2) 4))
(e (+ 1 d)))
(list a b c d e))
;; => ;; (1 2 3 4 5)
Note: clojure also has destructuring for maps etc. Didn't have this need
yet,
but guess the macro could be modified to accommodate destructuring
hashmaps, inlets etc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20200910/85054920/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: s7-let-destructuring.scm
Type: text/x-scheme
Size: 1845 bytes
Desc: not available
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20200910/85054920/attachment.bin>
More information about the Cmdist
mailing list