[Haskell-cafe] Confused about types

Lanny Ripple lanny at cisco.com
Thu Oct 6 09:15:32 EDT 2005


Thanks for the feedback.  It was basically a disposable example 
of something to learn the language with.  All the examples in all 
the tutorials are toy problems and all the systems put forward as 
having been written in haskell are huge.  A collection of medium 
solutions that folks could use to see how someone who knows the 
language would solve the problem would go a long way to bridge 
the gap.

   -ljr

Henning Thielemann wrote:
> On Fri, 30 Sep 2005, Lanny Ripple wrote:
> 
> 
>>newton_h, next_x_h, dy_h :: (Fractional a, Ord a) => (a -> a) ->
>>a -> a -> a
>>newton_h f x h = until ((<= h) . abs . f) (next_x_h f h) x
> 
> 
>  If this shall be more than a disposable example, I suggest to separate
> the Newton iteration from the abort of the iteration. Newton's method
> could return a list of the interim results, a sequence in the mathematical
> sense.
>   newton :: Fractional a => (a -> (a,a)) -> a -> [a]
>  The function would compute both the value and the derivative,
>   e.g. (\x -> (sin x, cos x))
> 
>  Then you can easily apply various implementations of a numeric limit.
>   limit :: [a] -> a
>    The most simple implementation is certainly: limit = (!!100)
> 
>  Eventually a function
>   numericDiff :: Fractional a => a -> (a -> a) -> (a -> (a,a))
>    could extend a function by some difference quotient.

-- 
Lanny Ripple <lanny at cisco.com>
CC Tools / Cisco Systems, Inc.


More information about the Haskell-Cafe mailing list