Reference FIB {1 1 loop[2dup +]} Problem TEST until[readline dup "42" =]: print Problem PRIME1 readint times: primes readint upfrom readint upto each[print] "" print @primes: {2} 3 loop: #candidate dup candidate sqrt upto exists[#p candidate p% 0=] if_f: candidate push candidate 2 + Problem SBSTR1 24 times: readitem readitem contains 1 0 ? print Problem ONP ?\Simple Grammar ?\ atom := a-z | (term) ?\ exp := atom ^ atom | atom ?\ div := exp / exp | exp ?\ mul := div * div | div ?\ sub := mul - mul | mul ?\ term := sub + sub | sub readint times: readline parseatom drop "" print @parseatom: #{x>xs} if(x '(' =): xs parseterm \) match elseif(x 'a' >=, x 'z' <=, &): x write xs else: `badchar !match: if(over head =)[tail] else[`badchar] !parseterm: parsesub dup head '+' = if_t: tail parsesub '+' write !parsesub : parsemul dup head '-' = if_t: tail parsemul '-' write !parsemul : parsediv dup head '*' = if_t: tail parsediv '*' write !parsediv : parseexp dup head '/' = if_t: tail parseexp '/' write !parseexp : parseatom dup head '^' = if_t: tail parseatom '^' write Problem ONP ?\Alternative Grammar ?\ atom := a-z | (term) ?\ exp := atom ^ exp | atom ?\ div := exp / div | exp ?\ mul := div * mul | div ?\ sub := mul - sub | mul ?\ term := sub + term | sub readint times: readline parseatom drop "" print @parseatom: #{x>xs} if(x '(' =): xs parseterm \) match elseif(x 'a' >=, x 'z' <=, &): x write xs else: `badchar !match: if(over head =)[tail] else[`badchar] !parseterm: parsesub dup head '+' = if_t: tail parseterm '+' write !parsesub: parsemul dup head '-' = if_t: tail parsesub '-' write !parsemul: parsediv dup head '*' = if_t: tail parsemul '*' write !parsediv: parseexp dup head '/' = if_t: tail parsediv '/' write !parseexp: parseatom dup head '^' = if_t: tail parseexp '^' write Problem ONP ?>Regex Demot\)/ t]`[#/a-z>a/ a] !term:{#/[sub]>s\+[term]>t/ s.. t.. '+'}`[#/[sub]>s/ s]# !sub:{#/[mul]>m\-[sub]>s/ m.. s.. '-'}`[#/[mul]>m/ m]# !mul:{#/[div]>d\*[mul]>m/ d.. m.. '*'}`[#/[div]>d/ d]# !div:{#/[exp]>e\/[div]>d/ e.. d.. '/'}`[#/[exp]>e/ e]# !exp:{#/[atom]>a\^[exp]>e/ a.. e.. '^'}`[#/[atom]>a/ a]#