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 BAA10072; Fri, 5 Jul 2002 01:54:23 +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 BAA10577 for ; Fri, 5 Jul 2002 01:54:22 +0200 (MET DST) Received: from postfix3-2.free.fr (postfix3-2.free.fr [213.228.0.169]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g64NsLH10765 for ; Fri, 5 Jul 2002 01:54:21 +0200 (MET DST) Received: from lfs (strasbourg-2-a7-62-147-12-166.dial.proxad.net [62.147.12.166]) by postfix3-2.free.fr (Postfix) with SMTP id 93E3217F46 for ; Fri, 5 Jul 2002 01:54:20 +0200 (CEST) Date: Fri, 5 Jul 2002 02:02:33 +0200 From: Nicolas FRANCOIS (AKA El Bofo) To: caml-list@inria.fr Subject: Re: [Caml-list] Objects or modules ? Message-Id: <20020705020233.49e022fa.nicolas.francois@free.fr> In-Reply-To: <20020704011611.621c2fbf.nicolas.francois@free.fr> References: <20020629031458.4d0c7fe9.nicolas.francois@free.fr> <20020629102252.GA29416@fichte.ai.univie.ac.at> <20020704011611.621c2fbf.nicolas.francois@free.fr> X-Mailer: Sylpheed version 0.7.6 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Le Thu, 4 Jul 2002 01:16:11 +0200 Nicolas FRANCOIS (AKA El Bofo) a écrit : > Le Sat, 29 Jun 2002 12:22:52 +0200 Markus Mottl a > écrit: > > > You might also want to take a look at Christophe Raffalli's library > > for formal and numerical calculus to grab a few ideas: > > > > http://lama-d134.univ-savoie.fr/sitelama/Membres/pages_web/RAFFALLI/formel.html > > OK, I got it. If I really understand this, this is a pre-project for > FOC. Am I right ? > > Now that I adapted it to OCaml 3.04 (Streams not recognized by standard > OCaml now), I have a new problem : this is a definition for a quotient > ring (there's a similar one for a quotient field in case the ideal is > primitive) ; > > (in algebra.mli) > module Quotient : > functor(R : Euclidian_Ring) -> > functor(Elt : One_element with type elem = R.elem) -> > Ring with type elem = R.elem > > (in algebra.ml) > module Quotient = > functor (R : Euclidian_Ring) -> > functor (Elt : One_element with type elem = R.elem) -> > struct > type elem = R.elem > let zero = R.zero > let one = R.one > let t_of_int = R.t_of_int > let (++) = R.(++) > let (--) = R.(--) > let ( ** ) = R.( ** ) > let (==) a b = R.(==) (R.(mod) (R.(--) a b) Elt.elt) R.zero > let opp = R.opp > let normalize x = R.(mod) (R.normalize x) Elt.elt > let print x = R.print (normalize x) > let write ch x = R.write ch (normalize x) > let parse = R.parse > let read = R.read > let write_bin ch x = R.write_bin ch (normalize x) > let read_bin = R.read_bin > let conjugate = R.conjugate > end > > I'd like to use this functor to create a ring Z/pZ, providing a > (possibliy prime) integer p. My problem is : what is the correct way to > use this ? OK, I found a way : (file essai.ml) open Algebra module Five : (One_element with type elem = Ring_MZ.elem) = struct type elem = Ring_MZ.elem let elt = Ring_MZ.t_of_int 5 end open Five module Z5Z = Quotient_prime (Ring_MZ) (Five) open Polynomial module P = Make(Z5Z) open P let p1 = monome (Z5Z.t_of_int 8) 0 ++ monome (Z5Z.t_of_int 4) 1 ++ monome (Z5Z.t_of_int 1) 2;; let p2 = monome (Z5Z.t_of_int 3) 1 ++ monome (Z5Z.t_of_int 1) 12 ++ monome (Z5Z.t_of_int 2) 14;; print (p1 ** (p2 // p1) ++ (p2 mod p1) -- p2) (The end for the ones how know the package Formel) Is there a way to do things simpler ? \bye -- Nicolas FRANCOIS http://nicolas.francois.free.fr A TRUE Klingon programmer does NOT comment his code ------------------- 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