Created
August 15, 2017 16:26
-
-
Save b4284/3399474eae6184002b1d17e72c1754e9 to your computer and use it in GitHub Desktop.
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
| -- A easy to use multiple-return-value is equivalent of having | |
| -- an automatic packing & unpacking mechanism of the functions' | |
| -- input & output. | |
| function mv(n) | |
| if n == 0 then | |
| return | |
| else | |
| return n, mv(n - 1) | |
| end | |
| end | |
| -- See the equivalent code in Scheme: | |
| -- | |
| -- (define (mv ls) | |
| -- (let ((n (car ls))) | |
| -- (if (zero? n) | |
| -- '() | |
| -- (cons n (mv (list (- n 1))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment