From: Lenny Gray <lgray@starsight.com>
To: "'caml-list@inria.fr'" <caml-list@inria.fr>
Subject: re: help an o'caml beginner
Date: Thu, 27 Jul 2000 11:43:41 -0700 [thread overview]
Message-ID: <95C632784DAFD31183CF00C00D015099060207@GDCMAIL2> (raw)
At 11:51 7/26/2000 -0600, John BEPPU wrote:
>
> ...
>
>If anyone out there could implement an O'Caml fibonacci number
>generator that doesn't make redundant calculations, I would really
>appreciate it. I just need something to study.
Of course a trivial approach would be to accept the fact
that O'Caml _has_ true assignable variables, via references.
However, since you sound like you want the _functional_
answer, the insight you're looking for is:
let rec f v1 v2 i = if i=0 then v2 else f v2 (v1+v2) (i-1);;
then: f 0 1 0 == 1
f 0 1 1 == 1
f 0 1 2 == 2
...
f 0 1 10 == 89
- Lenny -
next reply other threads:[~2000-07-27 21:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-07-27 18:43 Lenny Gray [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-08-02 17:28 Brent Fulgham
2000-07-27 22:50 John R Harrison
2000-07-28 12:49 ` John BEPPU
2000-07-27 18:24 Brent Fulgham
2000-07-26 17:51 John BEPPU
2000-07-27 18:47 ` Alain Frisch
2000-07-27 18:56 ` Markus Mottl
2000-07-29 17:03 ` John BEPPU
2000-07-29 17:23 ` Markus Mottl
2000-07-31 7:11 ` Vitaly Lugovsky
2000-07-31 8:43 ` Markus Mottl
2000-07-27 18:57 ` Remi VANICAT
2000-07-27 19:08 ` Jean-Christophe Filliatre
2000-07-27 21:31 ` Laurent Chéno
2000-07-27 23:47 ` Michel Quercia
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=95C632784DAFD31183CF00C00D015099060207@GDCMAIL2 \
--to=lgray@starsight.com \
--cc=caml-list@inria.fr \
--cc=lenny@aliveness.com \
/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