hikari-no-yume / Firth

Firth is a functional, strongly dynamically-typed, concatenative stack-oriented programming language.
Other
29 stars 2 forks source link

Add copy #33

Closed raoulvdberge closed 9 years ago

raoulvdberge commented 9 years ago

As described in http://www.ugrad.math.ubc.ca/Flat/stack-ref.html#PScopy

obn ... ob1 n copy obn ... ob1 obn ... ob1 This operator adds a copy of the top n objects on the stack.

For example, after executing this:

10 20 2 copy.

The stack would contain: 10 20 10 20

I had to make some changes in typeCheck so it would allow a callback, because I can't retrieve how much values of any it would return after executing.