mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 12:18:07 +11:00
e31527f5ac
There are many situations where it can be useful. Worth it.
12 lines
503 B
Plaintext
12 lines
503 B
Plaintext
: _pd ( a -- n f, parse decimal )
|
|
C@+ OVER C@ 0 ( a len firstchar startat )
|
|
( if we have '-', we only advance. more processing later. )
|
|
SWAP '-' = IF 1+ THEN ( a len startat )
|
|
( if we can do the whole string, success. if _pdacc returns
|
|
false before, failure. )
|
|
0 ROT> ( len ) ( startat ) DO ( a r )
|
|
OVER I + C@ ( a r c ) _pdacc ( a r f )
|
|
NOT IF DROP 1- 0 UNLOOP EXIT THEN LOOP ( a r )
|
|
( if we had '-', we need to invert result. )
|
|
SWAP C@ '-' = IF 0 -^ THEN 1 ( r 1 ) ;
|