Created
September 21, 2016 21:36
-
-
Save Maddix/9412e6c4c9a243c8d044918e09383430 to your computer and use it in GitHub Desktop.
Unpack items from a list into variables in a let statment
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
| ;;;; NewLisp | |
| (context 'let-unpack) ; (let-unpack (a b c (list 1 2 3)) (+ a b c)) -> 6 | |
| (define-macro (let-unpack:let-unpack expressions body) | |
| (letn (rev (reverse expressions) syms (apply list (reverse (rest rev))) vals (eval (first rev))) | |
| (eval (letex (expression (map (fn (symb val) (list symb val)) syms vals) body body) | |
| '(let expression body))))) | |
| (context MAIN) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment