io_calculator/program.txt

47 lines
550 B
Plaintext

clear
'defun '; defun
0 '_ 'noop ;
''~ '~ 'exec_if_0 '_ 'exec 'if_0_else ;
''noop '~ 'if_0_else 'exec_if_not_0 ;
'= 0 '= '!= ;
'read_word ': ''} '!= ''{ '~ ''_ '~ 'if_0_else '{ ;
{ quit q } ;
{ quit exit } ;
{ quit :q } ;
{ quote " } ;
{ clear cl } ;
{ ~ swap } ;
{ : dup } ;
{ 1 + ++ } ;
{ 1 - -- } ;
{ ~ _ backpop } ;
{ > ~ < } ;
{ : 1 - : 'countdown ~ exec_if_not_0 countdown } ;
{ size 2 - cons } ;
{ deref head } ;
{ ++ deref tail } ;
{ : 'next ~ 'current ~ if_0_else nth } ;
{ _ head current } ;
{ -- ~ tail ~ nth next } ;