thanks, the type problem is solved. but is there a way to write nested
functions? so the powerf isn't exposed outwards...

and how can I rewrite the if statements in a case or cond way? pattern
mathcing is only on types right? cond a la scheme would be nice.

let rec powerf(n, pow, acc) =
    if pow > 0.0
        then powerf(n, pow -. 1., acc *. n)
        else if pow < 0.0
            then 1. /. powerf(n, pow *. (-1.), acc)
            else acc ;;
let power(n, pow) = powerf(n, pow, 1.);;



---------- Forwarded message ----------
From:  <[EMAIL PROTECTED]>
Date: Wed, Sep 3, 2008 at 7:27 AM
Subject: Re: [Caml-list] is there a switch or cond-statement? + type-problem
To: circ ular <[EMAIL PROTECTED]>


On Wed, Sep 03, 2008 at 06:55:22AM +0200, circ ular wrote:
> thanks, not it compiles but I get this error instead:
> # powerx(5.0,2.0);;
> Characters 6-15:
>   powerx(5.0,2.0);;
>         ^^^^^^^^^
> This expression has type float * float but is here used with type
>   float * float * float
> #

The error message tells you: You called powerx with two float parameters,
but you need three float parameters. When loooking at the definition
you see that you forgot to give the argument for the accumulator. Try
calling i as powerx(5., 2., 1.) instead :)

With kind regards,

-Martin

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to