Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Simple Math Function (Lorenzo Isella)


----------------------------------------------------------------------

Message: 1
Date: Fri, 10 Sep 2010 18:35:45 +0200
From: Lorenzo Isella <[email protected]>
Subject: [Haskell-beginners] Simple Math Function
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Dear All,
I am trying to translate some codes of mine into haskell. It looks like 
Haskell can shorten quite a bit the implementation of mathematical formulas.
Let us say you have two list of real numbers; let us call them y and t.
The list t is increasing (a sort of time).
Now consider the couples (t_a, y_a) and (t_b,y_b) where
t_a<t_b i.e.  two (non-simultaneous) values of t and the corresponding 
y_a and y_b. There are no assumptions on y.
What I would like to write is a function which checks the existence 
(t_c,y_c), where y_a<y_c<y_b (i.e. y_c is some intermediate time) such that

y_c<y_b+(y_a-y_b)*(t_b-t_c)/(t_b-t_a).

I have already implemented this in other languages, but I ended up with 
quite lengthy functions (what if a list is empty, what if it has fewer 
than 2-3 elements and so on...).
Also, it would be nice to iterate this function on all possible 
combinations (t_a, y_a) and (t_b,y_b), t_a<t_b I can form from my data.
I am not asking someone to 'do my homework', rather I would like to see 
how much more compact things can get in haskell.
Many thanks

Lorenzo


------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 27, Issue 24
*****************************************

Reply via email to