Sierpinski's triangle in Joy

Ivan Tomac — 2004-02-19 22:51:06

I've done this last night in about 15 minutes so there's probably
room for improvement.

DEFINE

single-iteration ==
dup [[dupd dupd swap concat concat] map [dup concat] dip] dip
dup zip [i " " swap concat concat] map concat;

sierpinski ==
[" " [" * " "* *"]] dip [single-iteration] times popd.

4 sierpinski ["\n" concat] map "" [concat] fold putchars.

quit.

Ivan Tomac — 2004-02-20 03:20:13

--- In concatenative@yahoogroups.com, "Ivan Tomac" <e1_t@y...> wrote:
> I've done this last night in about 15 minutes so there's probably
> room for improvement.
>
> DEFINE
>
> single-iteration ==
> dup [[dupd dupd swap concat concat] map [dup concat] dip] dip
> dup zip [i " " swap concat concat] map concat;
>
> sierpinski ==
> [" " [" * " "* *"]] dip [single-iteration] times popd.

The first string should contain 2 spaces - for some reason this
didn't paste properly. It also messed up the indenting when i pasted
it.

>
> 4 sierpinski ["\n" concat] map "" [concat] fold putchars.
>
> quit.