Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created July 20, 2015 06:04
Show Gist options
  • Select an option

  • Save shigemk2/af20f9239ee88b66f10b to your computer and use it in GitHub Desktop.

Select an option

Save shigemk2/af20f9239ee88b66f10b to your computer and use it in GitHub Desktop.
import Data.List.Split
pn str = fst $ pnPrime $ splitOn " " str
pnPrime ("+":xs) =
let (a, n1) = pnPrime(xs)
(b, n2) = pnPrime(n1)
in (a + b, n2)
pnPrime src = ((read $ head src :: Int), tail src)
main = do
print $ pn "1"
print $ pn "+ 1 2"
print $ pn "+ 1 + 2 3"
print $ pn "+ + 1 2 3"
print $ pn "+ + 1 2 + 3 4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment