Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- : doubledip ( -- n )
- dup dup +
- ;
- : fact1 ( n -- n! ) recursive \ recursive declaration
- dup 1 > if dup 1- fact1 * then
- ;
- : fact2 ( n -- n! ) \ recurse instead of calling function
- dup 1 > if dup 1- recurse * then
- ;
- variable thing1 \ make a variable
- 10 thing1 ! \ put 10 on the stack, and ! stores it in "thing1"
- 0 value thing2 \ make a variable called "thing2", must have an actual value before "value"
- 12 to thing2 \ "to" can put stuff in "thing2"
- 4 doubledip
- swap drop
- thing1 @ fact2 \ @ fetches from "thing1" and puts it on the stack
- thing2 fact1 \ "thing2" can fetch it's own value if it's defined with "value"
- .s bye
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement