From: Dustin Sallings <dustin@spy.net>
To: ijtrotts@ucdavis.edu
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Python's yield, Lisp's call-cc or C's setjmp/longjmp in OCaml
Date: Wed, 17 Dec 2003 00:13:01 -0800 [thread overview]
Message-ID: <D4D0BF52-3068-11D8-9487-000393CB0F1E@spy.net> (raw)
In-Reply-To: <200312162230.23322.ijtrotts@ucdavis.edu>
On Dec 16, 2003, at 22:30, ijtrotts@ucdavis.edu wrote:
> Why not do this:
>
> # let rec number() =
> let i=ref(-1) in fun() ->
> incr i;
> !i, if !i mod 2 = 0 then "Even" else "Odd";;
> val number : unit -> unit -> int * string = <fun>
> # let n=number();;
> val n : unit -> int * string = <fun>
> # Array.init 10 (fun _ -> n());;
> - : (int * string) array =
> [|(0, "Even"); (1, "Odd"); (2, "Even"); (3, "Odd"); (4, "Even"); (5,
> "Odd");
> (6, "Even"); (7, "Odd"); (8, "Even"); (9, "Odd")|]
>
> ?
>
> Issac
That's nice. Given this type of construct and raise, is there
anything you can do with a continuation that would really be missed?
(I'm showing my ignorance of the value of call/cc)
--
SPY My girlfriend asked me which one I like better.
pub 1024/3CAE01D5 1994/11/03 Dustin Sallings <dustin@spy.net>
| Key fingerprint = 87 02 57 08 02 D0 DA D6 C8 0F 3E 65 51 98 D8 BE
L_______________________ I hope the answer won't upset her. ____________
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2003-12-17 8:13 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-16 13:13 Nuutti Kotivuori
2003-12-16 13:28 ` Oleg Trott
2003-12-18 0:15 ` Nuutti Kotivuori
2003-12-16 13:48 ` Ville-Pertti Keinonen
2003-12-16 15:41 ` Kenneth Knowles
2003-12-16 16:45 ` Richard Jones
2003-12-16 18:36 ` Ville-Pertti Keinonen
2003-12-16 18:42 ` Brian Hurt
2003-12-16 18:10 ` Dustin Sallings
2003-12-17 6:30 ` ijtrotts
2003-12-17 8:13 ` Dustin Sallings [this message]
2003-12-17 10:35 ` Falk Hueffner
2003-12-17 19:14 ` Pierre Weis
2003-12-17 19:32 ` Falk Hueffner
2003-12-17 20:04 ` David Brown
2003-12-18 1:14 ` Nicolas Cannasse
2003-12-18 5:31 ` David Brown
2003-12-18 7:05 ` Brian Hurt
2003-12-18 6:45 ` David Brown
2003-12-18 18:44 ` brogoff
2003-12-17 19:42 ` brogoff
2003-12-19 13:39 ` skaller
2003-12-18 0:51 ` Nuutti Kotivuori
2003-12-16 18:06 Kevin S. Millikin
2003-12-18 22:08 Ker Lutyn
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=D4D0BF52-3068-11D8-9487-000393CB0F1E@spy.net \
--to=dustin@spy.net \
--cc=caml-list@inria.fr \
--cc=ijtrotts@ucdavis.edu \
/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