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 AAA10564; Sat, 4 May 2002 00:21:15 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA10684 for ; Sat, 4 May 2002 00:21:14 +0200 (MET DST) Received: from smarthost0.mail.uk.easynet.net (smarthost0.mail.uk.easynet.net [212.135.6.10]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g43MLCP12290; Sat, 4 May 2002 00:21:12 +0200 (MET DST) Received: from tnt-9-128.easynet.co.uk ([195.40.198.128] helo=7p8420j) by smarthost0.mail.uk.easynet.net with smtp (Exim 3.35 #1) id 173lQN-000HCp-00; Fri, 03 May 2002 23:21:11 +0100 Message-Id: <4.1.20020503225838.009b61b0@127.0.0.1> X-Sender: daveb/pophost.tardis.ed.ac.uk@127.0.0.1 X-Mailer: QUALCOMM Windows Eudora Pro Version 4.1 Date: Fri, 03 May 2002 23:12:14 +0100 To: Francois.Pottier@inria.fr, Dave Berry From: Dave Berry Subject: Re: [Caml-list] How to read three integers from a text-file... ? Cc: caml-list@inria.fr In-Reply-To: <20020430142015.B21691@pauillac.inria.fr> References: <4.1.20020430114454.009caaf0@127.0.0.1> <20020424212316.GA26318@cs.net.pl> <15557.14957.358556.545541@absurd.mimuw.edu.pl> <20020424212316.GA26318@cs.net.pl> <20020429084410.A3490@pauillac.inria.fr> <4.1.20020430114454.009caaf0@127.0.0.1> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk At 14:20 30/04/2002, Francois Pottier wrote: >The function that concatenates CPS-encoded tuples is as follows: > > let (++) tuple1 tuple2 k = > tuple2 (tuple1 k) > >A simple ``tuple'' that contains one integer (read from standard input >when the tuple is queried) is > > let int k = > k (int_of_string (input_line stdin)) Neat. In practice you'd want to thread the input stream (or possibly the input operation) through the combinators. >You can then read, say, three integers from standard input and compute >something out of them in the following way: > > (int ++ int ++ int) (fun x y z -> x + y * z) Perhaps it would be neat to have some syntactic sugar for this, e.g.: bind = in end as sugar for (fun -> ) (This is simply the opposite application order from the expansion of "let" bindings: let = in end is sugar for (fun -> ) (). Of course, the types are different, and "let" bindings also generalise type variables). Dave.] ------------------- 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