Skip to content

Instantly share code, notes, and snippets.

@evrim
Created November 14, 2012 14:58
Show Gist options
  • Save evrim/4072586 to your computer and use it in GitHub Desktop.
Save evrim/4072586 to your computer and use it in GitHub Desktop.
applicative linear algebra
vectorSpace ∷ (Enum a1, Eq a, Num a1, Num a, Ord a1) ⇒ a1 → a → [[a1]]
vectorSpace q 0 = [[]]
vectorSpace q n | q > 0 = (:) <$> [0..q-1] <*> (vectorSpace q $ n - 1)
vectorSpace _ _ = error "vectorSpace"
*Main Numeric.LinearAlgebra> length $ vectorSpace 2 (2^3)
256
*Main Numeric.LinearAlgebra> length $ vectorSpace 2 (2^4)
65536
*Main Numeric.LinearAlgebra> length $ vectorSpace 2 (2^5)
Process haskell killed
@evrim
Copy link
Author

evrim commented Nov 14, 2012

*Main Numeric.LinearAlgebra> length $ vectorSpace 2 (2^5)

Process haskell killed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment