Mandelbrot Set Generators in Joy

Nick Forde [nickf@system-7.freeserve.co.uk]
Creation Date: Wed Apr 10 2002
Last Updated: Mon Apr 15 2002

Contents


1. Introduction

The following simple Mandelbrot set generator example was discussed on the "concatenative" mailing list in March 2002 under the subject title, "Another imperative example in Joy". This document is a reference to the implementations provided on the list. For more details see the mailing list archive. Suggested alternative implementations would be most welcome.


2. ANSI-C Implementation

This simple implementation was based on some Basic code written back in the 1980's. There are lots of variations on this floating around the net.


3. Joy Implementation 1

This was my naive attempt which tried to be clear and flexible but is not at all elegant.


4. Joy Implementation 2

Louis Madon offered the following solution: Note that "pair" is not defined in some newer versions of Joy. It may be defined as "pair == unitlist cons;".


5. Joy Implementation 3

Louis also suggested the following potential enhancement:
For the main loop I had wanted to write:
Unfortunately there was nothing like a "slices" function that I could find - ie. take a list and slice it up into that number of equi-sized sublists. So I ended up deciding the 'n hack would be quicker than writing up 'slices' myself. But the slices solution would have been more elegant ...

6. Joy Implementation 4

Here's the previous example with one possible implementation of "slices". Note that for this variant it was necessary to increase the MEMORYMAX definition in globals.h from the Joy interpreter. Failing to do this results in an interpreter core dump.


7. Results

The output from the above implementations should look something like the following:
................::::::::::::::::::::::::::::::::::::::::::::...............
...........::::::::::::::::::::::::::::::::::::::::::::::::::::::..........
........::::::::::::::::::::::::::::::::::,,,,,,,:::::::::::::::::::.......
.....:::::::::::::::::::::::::::::,,,,,,,,,,,,,,,,,,,,,,:::::::::::::::....
...::::::::::::::::::::::::::,,,,,,,,,,,,;;;!:H!!;;;,,,,,,,,:::::::::::::..
:::::::::::::::::::::::::,,,,,,,,,,,,,;;;;!!/>&*|& !;;;,,,,,,,:::::::::::::
::::::::::::::::::::::,,,,,,,,,,,,,;;;;;!!//)|.*#|>/!;;;;;,,,,,,:::::::::::
::::::::::::::::::,,,,,,,,,,,,;;;;;;!!!!//>|:    !:|//!!;;;;;,,,,,:::::::::
:::::::::::::::,,,,,,,,,,;;;;;;;!!/>>I>>)||I#     H&))>////*!;;,,,,::::::::
::::::::::,,,,,,,,,,;;;;;;;;;!!!!/>H:  #|              IH&*I#/;;,,,,:::::::
::::::,,,,,,,,,;;;;;!!!!!!!!!!//>|.H:                     #I>!!;;,,,,::::::
:::,,,,,,,,,;;;;!/||>///>>///>>)|H                         %|&/;;,,,,,:::::
:,,,,,,,,;;;;;!!//)& :;I*,H#&||&/                           *)/!;;,,,,,::::
,,,,,,;;;;;!!!//>)IH:,        ##                            #&!!;;,,,,,::::
,;;;;!!!!!///>)H%.**           *                            )/!;;;,,,,,::::
                                                          &)/!!;;;,,,,,::::
,;;;;!!!!!///>)H%.**           *                            )/!;;;,,,,,::::
,,,,,,;;;;;!!!//>)IH:,        ##                            #&!!;;,,,,,::::
:,,,,,,,,;;;;;!!//)& :;I*,H#&||&/                           *)/!;;,,,,,::::
:::,,,,,,,,,;;;;!/||>///>>///>>)|H                         %|&/;;,,,,,:::::
::::::,,,,,,,,,;;;;;!!!!!!!!!!//>|.H:                     #I>!!;;,,,,::::::
::::::::::,,,,,,,,,,;;;;;;;;;!!!!/>H:  #|              IH&*I#/;;,,,,:::::::
:::::::::::::::,,,,,,,,,,;;;;;;;!!/>>I>>)||I#     H&))>////*!;;,,,,::::::::
::::::::::::::::::,,,,,,,,,,,,;;;;;;!!!!//>|:    !:|//!!;;;;;,,,,,:::::::::
::::::::::::::::::::::,,,,,,,,,,,,,;;;;;!!//)|.*#|>/!;;;;;,,,,,,:::::::::::
:::::::::::::::::::::::::,,,,,,,,,,,,,;;;;!!/>&*|& !;;;,,,,,,,:::::::::::::
...::::::::::::::::::::::::::,,,,,,,,,,,,;;;!:H!!;;;,,,,,,,,:::::::::::::..
.....:::::::::::::::::::::::::::::,,,,,,,,,,,,,,,,,,,,,,:::::::::::::::....
........::::::::::::::::::::::::::::::::::,,,,,,,:::::::::::::::::::.......
...........::::::::::::::::::::::::::::::::::::::::::::::::::::::..........
................::::::::::::::::::::::::::::::::::::::::::::...............


8. References

  1. Imperative thinking for Joy programs, Manfred von Thun.
  2. The Joy Homepage, Manfred von Thun.
  3. "Julia Sets and the Mandelbrot Set." In The Beauty of Fractals: Images of Complex Dynamical Systems A. Douady, (Ed. H.-O. Peitgen and D. H. Richter). Berlin: Springer-Verlag, 1986.