Jump to content

Barnsley fern: Difference between revisions

m
→‎{{header|R}}: Syntax highlighting.
(add F# version)
m (→‎{{header|R}}: Syntax highlighting.)
Line 2,370:
{{trans|PARI/GP}}
[[File:BarnsleyFernR.png|right|thumb|Output BarnsleyFernR.png]]
<lang rrsplus>## pBarnsleyFern(fn, n, clr, ttl, psz=600): Plot Barnsley fern fractal.
## Where: fn - file name; n - number of dots; clr - color; ttl - plot title;
## psz - picture size.
Line 2,416:
==='Obvious' solution===
The matrix solution above is a clever approach, but the following solution is more readable if you're unfamiliar with linear algebra. This is very much a blind "just do what the task says" solution. It's so simple that it probably runs unadapted in S. I suspect that there is room for an interesting use of R's ifelse function somewhere, but I couldn't find a clean way.
<lang rrsplus>fernOfNPoints<-function(n)
{
currentX<-currentY<-newX<-newY<-0
331

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.