According to the following website, "Ron Jeffries has ... been searching for a tidy and elegant solution, one which makes the rules of bowling as clear as possible."
http://www.randomhacks.net/articles/2007/04/28/bowling-in-haskell There may be better sites devoted to this task. I've accomplished, I think, accurate scoring calculation. Input is a valid series of balls; the result is the game score. I've attempted to write it in a manner that facilitates understanding by way of function names. I don't think it's anywhere near "showcase" quality. It is, however, at the point where I'm calling it as good as I can currently code. scoregame =: verb define tens =. 10&= # i...@# frame=. verb :'(#~ _1&~:)&.> _2<\ y #!._1~ 1j1 (ix #~ 2 ~:/\ 1, 2|ix=.tens y) } 1#~#y' bonus1 =. 10=+/ bonus2 =. 10={. scores =. [: > {. unscored=. }. laterballs=. verb :'2 {. ; }.y' framepins =. [: > {. bonus=. laterballs * [:(bonus1, bonus2) framepins oneframe=. [: +/ framepins, bonus scoreheadframe=. ([: < scores, [:oneframe unscored) , 2}.] +/ >{. scoreheadframe^:10 (a:,frame) y ) testballs=: 0 10, 4 4, 5 5, 9 1, 8 1, 10, 10, 0 10, 1 9, 10 10 3 scoregame testballs 162 scoregame 12#10 300 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
