Thun/docs/html/damnit.html

17 lines
1.9 KiB
HTML

<div class="discussion"><p>This works by building a little [while] program and running it:
1 3 [++] • [-- dip] cons [swap] infra [0 &gt;] swap while pop <br>
1 3 [++] [-- dip] • cons [swap] infra [0 &gt;] swap while pop <br>
1 3 [[++] -- dip] • [swap] infra [0 &gt;] swap while pop <br>
1 3 [[++] -- dip] [swap] • infra [0 &gt;] swap while pop
dip -- [++] • swap [3 1] swaack [0 &gt;] swap while pop <br>
dip [++] -- • [3 1] swaack [0 &gt;] swap while pop <br>
dip [++] -- [3 1] • swaack [0 &gt;] swap while pop <br>
1 3 [-- [++] dip] • [0 &gt;] swap while pop <br>
1 3 [-- [++] dip] [0 &gt;] • swap while pop
1 3 [0 &gt;] [-- [++] dip] • while pop
This is a common pattern in Joy. You accept some parameters from the
stack which typically include qouted programs and use them to build
another program which does the actual work. This is kind of like macros
in Lisp, or preprocessor directives in C.</p></div>