Sunflower fractal: Difference between revisions

Content deleted Content added
Added solution for Action!
Rdm (talk | contribs)
J implementation
Line 379:
sunflower.start();
}</lang>
 
=={{header|J}}==
 
This (currently draft) task really needs an adequate description. Still, it's straightforward to derive code from another implementation on this page.
 
This implementation assumes a recent J implementation (for example, J903):
 
<lang J>require'format/printf'
 
sunfract=: {{ NB. y: number of "sunflower seeds"
phi=. 0.5*1+%:5
XY=. (y%10)+(2*(I^phi)%seeds) * +.^j.2*1p1*phi*I=.1+i.y
XY,.(%:I)%13
}}
 
sunfractsvg=: {{)n
<svg xmlns="http://www.w3.org/2000/svg" width="%d" height="%d" style="stroke:gold">
<rect width="100%%" height="100%%" fill="black" />
%s
</svg>
}}{{
fract=. sunfract x
C=.,'\n<circle cx="%.2f" cy="%.2f" r="%.1f" />' sprintf fract
(m sprintf (;/<.20+}:>./fract),<C) fwrite y
}}</lang>
 
Example use:
 
<lang J>
3000 sunfractsvg '~/sunfract.html'
129147
</lang>
 
(The number displayed is the size of the generated file.)
 
=={{header|Julia}}==