Barnsley fern: Difference between revisions

Content added Content deleted
m (fix Java heading)
Line 23: Line 23:


Starting position: x = 0, y = 0
Starting position: x = 0, y = 0

=={{header|J}}==
'''Solution:'''
<lang j>require 'plot'

f=: _99 ". ];._2 noun define
0 0 0 0.16 0 0 0.01
0.85 0.04 -0.04 0.85 0 1.60 0.85
0.20 -0.26 0.23 0.22 0 1.60 0.07
-0.15 0.28 0.26 0.24 0 0.44 0.07
)

fm=: {&(_2 (]\"1) 4 {."1 f)
fa=: {&(4 5 {"1 f)
prob=: (+/\ 6 {"1 f) I. ?@0:

ifs=: prob (fa@[ + fm@[ +/ .* ]) ]
getPoints=: ifs^:(<200000)
plotFern=: 'dot;grids 0 0;tics 0 0;labels 0 0;color green' plot ;/@|:

plotFern getPoints 0 0</lang>


=={{header|Java}}==
=={{header|Java}}==