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 UAA10846; Tue, 3 Dec 2002 20:16:12 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA10835 for caml-list@pauillac.inria.fr; Tue, 3 Dec 2002 20:16:11 +0100 (MET) 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 KAA26199 for ; Tue, 3 Dec 2002 10:47:23 +0100 (MET) Received: from epita.fr (hermes.epita.fr [163.5.255.10]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gB39lMX17021 for ; Tue, 3 Dec 2002 10:47:23 +0100 (MET) Received: from goa.lrde.epita.fr (mail@goa.lrde.epita.fr [10.223.13.2]) by epita.fr id gB39lIe18844 for EPITA Paris France Tue, 3 Dec 2002 10:47:18 +0100 (MET) Received: from sandrock.lrde.epita.fr ([10.223.13.45] helo=sandrock) by goa.lrde.epita.fr with esmtp (Exim 3.35 #1 (Debian)) id 18J9eM-0005Ox-00 for ; Tue, 03 Dec 2002 10:47:30 +0100 Content-Type: text/plain; charset="iso-8859-1" From: Yann =?iso-8859-1?q?R=E9gis-Gianas?= (by way of Yann =?iso-8859-1?q?R=E9gis-Gianas?= ) Organization: LRDE Subject: Re: [Caml-list] arbitrarily large integers Date: Tue, 3 Dec 2002 10:47:09 +0100 User-Agent: KMail/1.4.3 To: caml-list@inria.fr MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200212031047.09974.yann@lrde.epita.fr> Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Le Mardi 3 D=E9cembre 2002 08:40, Scott J. a =E9crit : > Hi, =09Hello, > is it possible to implement in OCamel arbitrary large integers as > in Dolphin smalltalk e.g. where e.g. factorial 10000 is evaluated > very fast =09Yes, it's possible : just use the nums library (documented in the documentation at http://caml.inria.fr/ocaml/htmlman/manual036.html). =09An example : #load "nums.cma";; (* directly with Big_int ... *) open Big_int let fact n =3D let rec fact_ acu p =3D if p =3D zero_big_int then acu else fact_ (mult_big_int acu p) (sub_big_int p unit_big_int) in fact_ unit_big_int n;; string_of_big_int (fact (big_int_of_int 10000));; (* more convenient with Num. *) open Num let n_ =3D num_of_int let big_fact n =3D let rec fact_ acu p =3D if p =3D n_ 0 then acu else fact_ (acu */ p) (p -/ (n_ 1)) in fact_ (n_ 1) n;; string_of_num (big_fact (n_ 10000)) -- Yann Regis-Gianas ------------------- 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