visualising primes on a spiral

113 views
Skip to first unread message

Jeff Smits

unread,
Jul 31, 2015, 12:04:02 AM7/31/15
to elm-discuss

Hi folks,

I did a random thing in Elm, where by random thing I mean visual exploration of a bunch of primes when you show them on a spiral.
I picked an involute spiral because it sounded cool (it’s a spiral that has a constant distance between the curves). And I kept the distance between the dots on the spiral constant as well.

The code is not exactly pretty, but it’s short and heavy on math and toFloat so what can you do. It’s fun to explore this stuff visually though, especially if you keep the number of displayed primes low, so the influence of mouse movement on the pattern is clear. You can find some fairly regular looking patterns, like this:


David Legard

unread,
Jul 31, 2015, 9:10:58 AM7/31/15
to Elm Discuss, jeff....@gmail.com
Wot, no Euler's Sieve to generate the primes?

Shouldn't be more than 4 lines of Elm and would show off FP a treat.Woeuhtnaoesaoehsuokkkj

Max Goldstein

unread,
Jul 31, 2015, 10:12:53 AM7/31/15
to Elm Discuss, jeff....@gmail.com, dale...@gmail.com
Neat! I found a few other cool positions, one of which looks like an isometric projection.

And yes, it would be neat if you could compute the primes.



Jeff Smits

unread,
Jul 31, 2015, 1:34:40 PM7/31/15
to Max Goldstein, Elm Discuss, David Legard

Actually David, a proper sieve takes a little more than 4 lines.

Anyway, it wasn’t about getting the primes so I didn’t add that. It’s certainly possible to write that, and that would perhaps make it a good code example too, but this was just a little thing I hacked together on a late night :P

Hassan Hayat

unread,
Jul 31, 2015, 3:59:06 PM7/31/15
to Elm Discuss, maxgol...@gmail.com, dale...@gmail.com, jeff....@gmail.com
Can I interest y'all in an infinite list of primes?
https://gist.github.com/TheSeamau5/86dbfae8c4585d6c7e9e

Max Goldstein

unread,
Aug 1, 2015, 10:05:41 AM8/1/15
to Elm Discuss
Depends. Do I pay per prime or is it a flat fee for the lot?

Hassan Hayat

unread,
Aug 1, 2015, 12:05:15 PM8/1/15
to Elm Discuss
It's a flat fee for all the primes, but I'll allow you to pay for however many primes as a ratio of all the primes. So, if you see 20% of all the primes, you pay 20% of the fee. :D

Hassan Hayat

unread,
Aug 1, 2015, 1:41:55 PM8/1/15
to Elm Discuss
In a similar vein, I was just inspired right now by this gif on 9gag: http://9gag.com/gag/aQnRY5W  and I was wondering if I could reproduce it. Turns out it was quite easy and took me about 10 minutes. It basically worked on the first try. Now I know how to spirograph!

http://share-elm.com/sprout/55bd03f3e4b06aacf0e8b956

Max Goldstein

unread,
Aug 1, 2015, 7:46:50 PM8/1/15
to Elm Discuss, hassan...@gmail.com
I'll take the first googol primes, for a prorated price of free.

Jim Freeze

unread,
Aug 2, 2015, 3:58:00 PM8/2/15
to elm-d...@googlegroups.com
Very nice.

On Sat, Aug 1, 2015 at 12:41 PM, Hassan Hayat <hassan...@gmail.com> wrote:
In a similar vein, I was just inspired right now by this gif on 9gag: http://9gag.com/gag/aQnRY5W  and I was wondering if I could reproduce it. Turns out it was quite easy and took me about 10 minutes. It basically worked on the first try. Now I know how to spirograph!

http://share-elm.com/sprout/55bd03f3e4b06aacf0e8b956

--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Dr. Jim Freeze, Ph.D.
Reply all
Reply to author
Forward
0 new messages