Created
February 20, 2013 04:47
-
-
Save dimpase/4992965 to your computer and use it in GitHub Desktop.
A bit of CA in Haskell. The hardest part was to figure out nf, to ensure strict evaluation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Math.CommutativeAlgebra.Polynomial | |
import Math.Algebras.VectorSpace -- for nf | |
main = | |
print (adder 10000000 d e) | |
where | |
[x,y] = map glexvar ["x","y"] | |
a = 4*x^2 + 3*x + 2 | |
b = 5*x^2 + 6*x + 7 | |
c = 8*x^2 + 9*x + 10 | |
d = a*y^2 + b*y + c | |
e = d | |
adder n v u = adder' n u | |
where | |
adder' 0 acc = acc | |
adder' n acc = adder' (n-1) (nf (acc+v)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment