In my old article I have implementation for Cantor’s set without recursion. Now I implemented the Cantor’s set with recursion in JavaScript. This is better solution.

The definition of the Cantor’s set in the language of set theory is the following:

If this doesn’t mean anything to you, you might want to check the old post. ğŸ™‚

Below is a picture from the output of the program of this post:

Below is the JavaScript listing from Notepad++ in full as png-file:

You could also divide the segement length in the recursive call. This way you would get the first straight line directly…

### Like this:

Like Loading...

*Suositellut*