Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
( condition ) IF ( true statements ) THEN
|
||||
( condition ) IF ( true statements ) ELSE ( false statements ) THEN
|
||||
|
|
@ -0,0 +1 @@
|
|||
10 < IF ." Less than 10" ELSE ." Greater than or equal to 10" THEN
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
( n -- ) CASE
|
||||
( integer ) OF ( statements ) ENDOF
|
||||
( integer ) OF ( statements ) ENDOF
|
||||
( default instructions )
|
||||
ENDCASE
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
: test-case ( n -- )
|
||||
CASE
|
||||
0 OF ." Zero!" ENDOF
|
||||
1 OF ." One!" ENDOF
|
||||
." Some other number!"
|
||||
ENDCASE ;
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
: switch
|
||||
CREATE ( default-xt [count-xts] count -- ) DUP , 0 DO , LOOP ,
|
||||
DOES> ( u -- ) TUCK @ MIN 1+ CELLS + @ EXECUTE ;
|
||||
|
||||
:NONAME ." Out of range!" ;
|
||||
:NONAME ." nine" ;
|
||||
:NONAME ." eight" ;
|
||||
:NONAME ." seven" ;
|
||||
:NONAME ." six" ;
|
||||
:NONAME ." five" ;
|
||||
:NONAME ." four" ;
|
||||
:NONAME ." three" ;
|
||||
:NONAME ." two" ;
|
||||
:NONAME ." one" ;
|
||||
:NONAME ." zero" ;
|
||||
10 switch digit
|
||||
|
||||
8 digit \ eight
|
||||
34 digit \ Out of range!
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
: 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue