Created
December 26, 2009 05:25
-
-
Save lsparrish/263843 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) | |
| ( For loop with an index that counts from zero, placed on the ) | |
| ( top of the stack with each iteration. Uses NORS to keep ) | |
| ( track of the original value, so nexti must be used to clean ) | |
| ( up when loop is complete. ) | |
| ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) | |
| : fori ` dup ` push ` for ` pop ` pop ` 2dup | |
| ` push ` push ` swap ` - ; compile-only | |
| : nexti ` next ` pop ` drop ; compile-only | |
| ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) | |
| ( Convert counted and zero-terminated strings. ) | |
| ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) | |
| {{ | |
| create buffer 64 allot | |
| ---reveal--- | |
| : cs ( $-an ) tempString dup getLength ; | |
| : zt ( an-$ ) tuck buffer swap copy 0 swap buffer + ! buffer tempString ; | |
| : cstype fori over + @ emit nexti ; | |
| }} | |
| ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) | |
| ( Append/prepend counted strings. ) | |
| ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) | |
| {{ | |
| : sav ( n-n ) ` dup ` push ; | |
| ---reveal--- | |
| : csprepend ( anan-an ) | |
| here sav swap sav dup allot copy | |
| here swap sav dup allot copy | |
| pop pop + pop swap ; | |
| : csappend ( anan-an ) push -rot pop -rot prepend ; | |
| }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment