Paste: experiments

Author: prunedtree
Mode: factor
Date: Thu, 25 Dec 2008 15:18:12
Plain Text |
> { define } { compile swap set-word } compile swap set-word
>
> { slip } { >r call r> } define
> { dip } { swap slip } define
> { nip } { [ drop ] dip } define
> { over } { swap dup [ swap ] dip } define
> { 2dip } { swap [ dip ] dip } define
> { 2dup } { over over } define
>
> { keep } { over slip } define
> { bi } { [ keep ] dip call } define
> { tri } { [ [ keep ] dip keep ] dip call } define
> { 2keep } { [ 2dup ] dip 2dip } define
> { 2bi } { [ 2keep ] dip call } define
> { 2tri } { [ [ 2keep ] dip 2keep ] dip call } define
> { bi* } { [ dip ] dip call } define
> { tri* } { [ [ 2dip ] dip dip ] dip call } define
> { bi@ } { dup bi* } define
>
> { if } { ? call } define
> { when } { swap [ call ] [ drop ] if } define
> { unless } { swap [ drop ] [ call ] if } define
>
> { 1- } { 1 - } define
> { declare } { { } define }
>
> { fib } declare
> { fib } { dup 2 > [ [ 1- fib ] [ 2 - fib ] bi + ] when } define
> 10 fib .
:: 89
>

New Annotation

Summary:
Author:
Mode:
Body: