RosettaCodeData/Task/Metaprogramming/Quackery/metaprogramming.quackery

37 lines
1.1 KiB
Plaintext

( +---------------------------------------------------+ )
( | add inline comments ";" to Quackery with "builds" | )
( +---------------------------------------------------+ )
[ dup $ "" = not while
behead carriage =
until ] builds ; ( [ $ --> [ $ )
; +---------------------------------------------------+
; | add switch to Quackery with ]else[ ]'[ & ]done[ |
; +---------------------------------------------------+
[ stack ] is switch.arg ( --> s )
protect switch.arg
[ switch.arg put ] is switch ( x --> )
[ switch.arg release ] is otherwise
[ switch.arg share
!= iff ]else[ done
otherwise
]'[ do ]done[ ] is case ( x --> )
[ switch
1 case [ say "The number 1." cr ]
$ "two" case [ say 'The string "two".' cr ]
otherwise [ say "Something else." cr ] ] is test
( x --> )
' tally test ; output should be: Something else.
$ "two" test ; output should be: The string "two".
1 test ; output should be: The number 1.