
On Sun, 05 Feb 2012 09:19:02 +0100, Thomas Engel
Hello,
I have two list (one with x values, the other with y values) What I want to do is a numercial integration according the following formula:
Result x2 = Result x1 + ((y(x1) + y(x2))/2) * (x2 -x1)
and put the result in another list.
below my first try:
integriereListe::(a)->(a)->(a) integriereListe [][] = [0.0] integriereListe (x:xs) (y:ys) = ((y - y2) /2) * (x2 -x) where x2 = head xs y2 = head ys
The line
integriereListe [][] = [0.0] should be integriereListe [][] = 0.0 as the line below that calculates a number, not a list of numbers (that is, the type is different for that line). You than need to correct the type of the function. Note, that you use 'head' twice for lists that are empty at a certain point.
Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --