[Haskell-beginners] Simple Math Function
lorenzo.isella at gmail.com
Fri Sep 10 12:35:45 EDT 2010
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
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.
More information about the Beginners