Skip to content

Instantly share code, notes, and snippets.

@yuanmai
Created August 30, 2012 09:57
Show Gist options
  • Save yuanmai/3525188 to your computer and use it in GitHub Desktop.
Save yuanmai/3525188 to your computer and use it in GitHub Desktop.
Bowling Score in PicoLisp
(de frame @
(when (next)
(link
(make
(if (= 10 (link (arg)))
(apply link (head 2 (rest)))
(when (= 10 (+ (arg) (link (next))))
(link (car (rest))) ) ) ) )
(pass frame) ) )
(de score (Lst)
(apply +
(fish atom
(head 10
(make (apply frame Lst)) ) ) ) )
: (score (make (do 21 (link 1))))
(score (make (do 21 (link 1))))
-> 20
: (score (make (do 21 (link 5))))
(score (make (do 21 (link 5))))
-> 150
: (score (make (do 21 (link 10))))
(score (make (do 21 (link 10))))
-> 300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment