Skip to content

Instantly share code, notes, and snippets.

@crcx
Forked from lsparrish/gist:556671
Created September 8, 2010 00:32
Show Gist options
  • Save crcx/569391 to your computer and use it in GitHub Desktop.
Save crcx/569391 to your computer and use it in GitHub Desktop.
chain: parable
{{
create stack here , 10 allot
: push stack dup ++ @ ! ;
: pop stack dup @ @ swap -- ;
: empty? stack dup @ = ;
: nest compiler on here push 0 , 0 , ;
: unnest pop empty? not !compiler ;
---reveal---
: [ nest ; immediate
: ] unnest @compiler if 9 , here over 1+ ! 8 over ! 2 + 1 , , ;then 9 , ; immediate
}}
: __: header ; parsing
: def ( a- ) @last !d->xt &.word reclass ;
:do [ .word ] def
:if [ rot 0 !if drop .word ;then nip .word ] def
:ifTrue [ [ ] if ] def
:ifFalse [ [ ] swap if ] def
:dip [ swap push do pop ] def
:loop [ swap for dup dip next drop ] def
:loopi [ swap for r swap dup dip next drop ] def
;chain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment