Skip to content

Instantly share code, notes, and snippets.

@b4284
Created August 15, 2017 16:26
Show Gist options
  • Select an option

  • Save b4284/3399474eae6184002b1d17e72c1754e9 to your computer and use it in GitHub Desktop.

Select an option

Save b4284/3399474eae6184002b1d17e72c1754e9 to your computer and use it in GitHub Desktop.
-- 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