Category:Forth: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 24:
: muldiv { a b -- a*b a/b } \ all stuff after "--" is ignored
a b * a b / ;
 
Some counted string utilities:
: c+! ( n caddr -- ) dup >r c@ + r> c! ;
: append ( src len dest -- ) 2dup 2>r count + swap move 2r> c+! ;
: place ( src len dest -- ) 2dup 2>r 1+ swap move 2r> c! ;
: scan ( str len char -- str' len' ) >r begin dup while over c@ r@ <> while 1 /string repeat then r> drop ;
: skip ( str len char -- str' len' ) >r begin dup while over c@ r@ = while 1 /string repeat then r> drop ;
: split ( str len char -- str1 len1 str2 len2 ) >r 2dup r> scan 2swap 2 pick - ;
 
==Citations==
Anonymous user