RosettaCodeData/Task/Conditional-structures/Forth/conditional-structures-6.fth
2023-07-01 13:44:08 -04:00

15 lines
311 B
Forth

: CASE: ( <name>) CREATE ;
\ lookup execution token and compile
: | ( <name> ) ' compile, ;
: ;CASE ( n -- ) DOES> OVER + + @ EXECUTE ;
: FOO ." FOO" ;
: BAR ." BAR" ;
: FIZZ ." FIZZ" ;
: BUZZ ." BUZZ" ;
CASE: SELECT ( n -- ) | FOO | BAR | FIZZ | BUZZ ;CASE
\ Usage: 3 SELECT