RosettaCodeData/Task/Comma-quibbling/Forth/comma-quibbling.fth
2023-07-01 13:44:08 -04:00

16 lines
391 B
Forth

: read bl parse ;
: not-empty? ( c-addr u -- c-addr u true | false ) ?dup-if true else drop false then ;
: third-to-last 2rot ;
: second-to-last 2swap ;
: quibble
." {"
read read begin read not-empty? while third-to-last type ." , " repeat
second-to-last not-empty? if type then
not-empty? if ." and " type then
." }" cr ;
quibble
quibble ABC
quibble ABC DEF
quibble ABC DEF G H