From: "circ ular" <circularfunc@gmail.com>
To: caml-list@inria.fr
Subject: is there a switch or cond-statement? + type-problem
Date: Tue, 2 Sep 2008 05:23:16 +0200 [thread overview]
Message-ID: <d5f6b0140809012023g2c9bbbd9i4bb1383b80f5022@mail.gmail.com> (raw)
how can I do like this or use cond or case?
def power(nbr, po):
if po > 0:
return nbr * power(nbr, po-1)
if po < 0:
return 1 / power(nbr, -1 * po)
if po == 0:
return 1
and ofc make it tailrecursive but that I know how.
also, how do I get it to be a float-function?
let rec powerx(n, pow, acc) =
if pow > 0.0
then powerx(n, pow -. 1, acc *. n)
else if pow < 0.0
then 1.0 /. powerx(n, pow *. (-1), acc)
else acc ;;
Characters 70-71:
then powerx(n, pow -. 1, acc *. n)
^
This expression has type int but is here used with type float
#
but it is used with float evrywhere no?
next reply other threads:[~2008-09-02 3:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-02 3:23 circ ular [this message]
2008-09-02 4:02 ` Chris Conway
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d5f6b0140809012023g2c9bbbd9i4bb1383b80f5022@mail.gmail.com \
--to=circularfunc@gmail.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox