January 2018

S M T W T F S
  123456
78910111213
14151617181920
21222324252627
28293031   

Page Summary

Style Credit

Expand Cut Tags

No cut tags

October 19th, 2006

pozorvlak: (Default)
Thursday, October 19th, 2006 06:52 pm
I've decided that I should get to learn more about Haskell, because (from what [livejournal.com profile] totherme, [livejournal.com profile] michiexile and Duncan say) it sounds like it's got much cooler since I last touched it. So today I sat down to write a program to generate valid Siteswaps for juggling patterns. A siteswap is a list of throw heights: "5" means that you throw a ball sufficiently high that the next time it will be thrown is in five beats' time, and so on. So a Three-Ball Cascade is 3, Right Middle Left is 423, and so on. Wikipedia has more information. A candidate pattern is juggleable if you don't have two balls trying to land at the same time.

It took me about three hours and 53 lines, and a lot of that time was spent wrestling with the type system. Debug.Trace was invaluable, though a bit of a pain to use. Anyway, here's the code: do any of you clever Haskell types out there have any comments for how I could have done things better?

Haskell code )

Now, a quick take 10000 juggleablePatterns should keep me busy for the next several lifetimes...