From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA27073; Fri, 14 Jun 2002 22:43:16 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA27134 for ; Fri, 14 Jun 2002 22:43:15 +0200 (MET DST) Received: from web10705.mail.yahoo.com (web10705.mail.yahoo.com [216.136.130.213]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id g5EKhDP28523 for ; Fri, 14 Jun 2002 22:43:14 +0200 (MET DST) Message-ID: <20020614204313.60096.qmail@web10705.mail.yahoo.com> Received: from [216.69.69.135] by web10705.mail.yahoo.com via HTTP; Fri, 14 Jun 2002 13:43:13 PDT Date: Fri, 14 Jun 2002 13:43:13 -0700 (PDT) From: Shannon --jj Behrens Subject: Re: [Caml-list] static variables in a function To: caml-list@inria.fr In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Thank you all for your speedy, helpful responses! I am also happy to see rough concensus in the correct way to do this. Thanks Again, -jj --- Yutaka OIWA wrote: > >> On Fri, 14 Jun 2002 10:08:30 -0700 (PDT), Shannon > --jj Behrens said: > > Shannon> Hi, > Shannon> What is the correct OCAML idiom for > achieving the > Shannon> following psuedocode? > > Shannon> let get_chunk () = > Shannon> static chunks_list; > > Shannon> if List.is_empty chunks_list > Shannon> then chunks_list = get_more_chunks (); > Shannon> shift chunks_list > Shannon> ;; > > How about this? > > let get_chunk = > let chunks_list = ref [] in > fun () -> > ... > > -- > Yutaka Oiwa Yonezawa Lab., Dept. of > Computer Science, > Graduate School of Information Sci. & Tech., > Univ. of Tokyo. > , > > PGP fingerprint = C9 8D 5C B8 86 ED D8 07 EA 59 34 > D8 F4 65 53 61 __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com ------------------- 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