3 ms·
I tried to write a mandlebrot plotter in FXYT. There are a number of challenges! First FXYT only provides a bounded loop - this can be overcome with a bit of in
by nickcw 3y ago
I tried to write a mandlebrot plotter in FXYT. There are a number of challenges! First FXYT only provides a bounded loop - this can be overcome with a bit of inefficiency.
However the deepest stack manipulation allowed is 3 values - the R command (Rotate the three values at the top of the data stack) which makes things supremely awkward. It could do with an PICK instruction (duplicate the n-th on the stack). However as an old FORTH programmer you always knew were getting into trouble if you used PICK.
Despite these limitations I did figure out how to write a mandlebrot plotter. Alas it runs into an iterations limit if the depth is > 7, so here is a very low-res mandlebrot made with FXYT!
NNNN7[SDDN1024/RDDN1024/R+N4096<[RN1+RR]SDDN1024/RDDN1024/R+N4096<![PPN4000N4000]SDDN1024/RDDN1024/RS-XN128-N12N512-+RRN512/YN128-N12+]PPN30
You can cut and paste the string above into https://susam.net/fxyt.html https://susam.net/fxyt.html if you wish to see it!
Edit - looks like HN formatting mashes the code...
This link should work
https://susam.net/fxyt.html#NNNN7bSDDpN1024qRDDpN1024qRsN4096lbRN1sRRcSDDpN1024qRDDpN1024qRsN4096libPPN4000N4000cSDDpN1024qRDDpN1024qRSdXN128dN12pN512dsRRpN512qYN128dN12pscPPN30p https://susam.net/fxyt.html#NNNN7bSDDpN1024qRDDpN1024qRsN409...
- susam 3y agoGreat demo! Thanks for sharing! Copying the un-mangled code here for future reference: NNNN7[SDD*N1024/RDD*N1024/R+N4096<[RN1+RR]SDD*N1024/RDD*N1024/R+N4096<![PPN4000N4000]SDD*N1024/RDD*N1024/RS-XN128-N12*N512-+RR*N512/YN128-N12*+]PPN30* If you start a line in HN comment with 2 spaces, the line is reproduced verbatim. See https://news.ycombinator.com/formatdoc https://news.ycombinator.com/formatdoc for more details about this.