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 GAA26716; Tue, 4 Sep 2001 06:51:21 +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 GAA27173 for ; Tue, 4 Sep 2001 06:51:20 +0200 (MET DST) Received: from csem.is.s.u-tokyo.ac.jp (csem.is.s.u-tokyo.ac.jp [133.11.30.87]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f844pIf02989 for ; Tue, 4 Sep 2001 06:51:19 +0200 (MET DST) Received: from localhost (cses0g [133.11.30.80]) by csem.is.s.u-tokyo.ac.jp (8.11.3/3.7W08/27/99) with ESMTP id f844p9P28275 for ; Tue, 4 Sep 2001 13:51:09 +0900 (JST) Date: Tue, 04 Sep 2001 13:51:08 +0900 (JST) Message-Id: <20010904.135108.68540667.tsuyoshi@is.s.u-tokyo.ac.jp> To: caml-list@inria.fr Subject: Re: [Caml-list] function type confusion (using let) From: ITO Tsuyoshi In-Reply-To: <20010902225140.A22597@ip178.usw22.rb1.bel.nwlink.com> References: <20010902222555.A22545@ip178.usw22.rb1.bel.nwlink.com> <20010902225140.A22597@ip178.usw22.rb1.bel.nwlink.com> X-Mailer: Mew version 2.0.50 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Michael Leary Subject: Re: [Caml-list] function type confusion (using let) Date: Sun, 2 Sep 2001 22:51:40 -0700 Message-ID: <20010902225140.A22597@ip178.usw22.rb1.bel.nwlink.com> > Well, this compiles, but looks funny: > > let normr r = > let x = mod_float r pi2 in > match x > 0.0 with > | true -> > if x > pi then > -.pi2 +. x > else > x > | false -> > if x < -.pi then > pi2 +. x > else > x > > Is there a different way? I'm not sure if I got what you mean correctly, but I think you can write: let normr r = let x = mod_float r pi2 in if x > 0.0 then begin if x > pi then -.pi2 +. x else x end else begin if x < -.pi then pi2 +. x else x end (Two begin-end pairs are not necessary in the code above but they are for readability; in case you are confused by them, just ignore them.) Of course you can write it in a more straightforward way if you don't care the order of the tests.... let normr r = let x = mod_float r pi2 in if x > pi then -.pi2 +. x else if x >= -.pi then x else pi2 +. x -- ITO Tsuyoshi -- ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr