Skip to content

Instantly share code, notes, and snippets.

@taiki45
Created February 25, 2014 14:52
Show Gist options
  • Save taiki45/9210318 to your computer and use it in GitHub Desktop.
Save taiki45/9210318 to your computer and use it in GitHub Desktop.
非決定計算で便利なリストモナドの性質
expects = do n1 <- [0..1]
n2 <- [0..1]
n3 <- [0..1]
n4 <- [0..1]
n5 <- [0..1]
return [n1, n2, n3, n4, n5]
expects' = sequence $ replicate 5 [0..1]
-- expects == expects' = True
-- [[0,0,0,0,0],[0,0,0,0,1],[0,0,0,1,0],[0,0,0,1,1],[0,0,1,0,0],[0,0,1,0,1],[0,0,1,1,0],[0,0,1,1,1],[0,1,0,0,0],[0,1,0,0,1],[0,1,0,1,0],[0,1,0,1,1],[0,1,1,0,0],[0,1,1,0,1],[0,1,1,1,0],[0,1,1,1,1],[1,0,0,0,0],[1,0,0,0,1],[1,0,0,1,0],[1,0,0,1,1],[1,0,1,0,0],[1,0,1,0,1],[1,0,1,1,0],[1,0,1,1,1],[1,1,0,0,0],[1,1,0,0,1],[1,1,0,1,0],[1,1,0,1,1],[1,1,1,0,0],[1,1,1,0,1],[1,1,1,1,0],[1,1,1,1,1]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment