Sierpinski triangle: Difference between revisions

(Add Uxntal (thanks neauoire))
Line 2,581:
: sierpinski ( n -- )
[ { "*" } " " ] dip (sierpinski) print ;</syntaxhighlight>
 
A more idiomatic version taking advantage of the '''''with''''', '''''each-integer''''', and '''''?''''' combinator as well as leveraging the looping combinator '''''each-integer'''''.
<syntaxhighlight lang="factor">USING: command-line io io.streams.string kernel math math.parser
namespaces sequences ;
IN: sierpinski
 
: plot ( i j -- )
bitand zero? "* " " " ? write ;
 
: pad ( n -- )
1 - [ " " write ] times ;
 
: plot-row ( n -- )
dup 1 + [ tuck - plot ] with each-integer ;
 
: sierpinski ( n -- )
dup '[ _ over - pad plot-row nl ] each-integer ;</syntaxhighlight>
 
=={{header|FALSE}}==
6

edits