caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] arbitrarily large integers
@ 2002-12-03  7:40 Scott J.
  2002-12-03 13:00 ` Jean-Christophe Filliatre
  2002-12-03 18:23 ` Alain.Frisch
  0 siblings, 2 replies; 4+ messages in thread
From: Scott J. @ 2002-12-03  7:40 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 166 bytes --]

Hi, is it possible to implement in OCamel arbitrary large integers as in Dolphin smalltalk e.g. where e.g. 
factorial 10000 is evaluatedvery fast.

thanks

Scott

[-- Attachment #2: Type: text/html, Size: 722 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] arbitrarily large integers
  2002-12-03  7:40 [Caml-list] arbitrarily large integers Scott J.
@ 2002-12-03 13:00 ` Jean-Christophe Filliatre
  2002-12-03 18:23 ` Alain.Frisch
  1 sibling, 0 replies; 4+ messages in thread
From: Jean-Christophe Filliatre @ 2002-12-03 13:00 UTC (permalink / raw)
  To: Scott J.; +Cc: caml-list


Scott J. writes:
 > Hi, is it possible to implement in OCamel arbitrary large integers as in Dolphin smalltalk e.g. where e.g. 
 > factorial 10000 is evaluatedvery fast.

The  Num  library  delivered  with ocaml  implements  arbitrary  large
naturals, integers and rationals. 
See http://caml.inria.fr/ocaml/htmlman/manual036.html

There are also

- an interface of the GNU MP library, by David Monniaux, at 
  http://www.di.ens.fr/~monniaux/download/mlgmp-20021123.tar.gz

- The Numerix library by Michel Quercia, at
  http://pauillac.inria.fr/~quercia/

Hope this helps,
-- 
Jean-Christophe 

-------------------
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] arbitrarily large integers
  2002-12-03  7:40 [Caml-list] arbitrarily large integers Scott J.
  2002-12-03 13:00 ` Jean-Christophe Filliatre
@ 2002-12-03 18:23 ` Alain.Frisch
  1 sibling, 0 replies; 4+ messages in thread
From: Alain.Frisch @ 2002-12-03 18:23 UTC (permalink / raw)
  To: Scott J.; +Cc: caml-list

On Tue, 3 Dec 2002, Scott J. wrote:

> Hi, is it possible to implement in OCamel arbitrary large integers as in Dolphin smalltalk e.g. where e.g.
> factorial 10000 is evaluatedvery fast.

Funny that you mention it, my CDuce prototype use OCaml Nums library to
implement integers, and fact 10000 is one of the examples:

http://www.cduce.org/cgi-bin/cduce?example=integers

I have no experience with other large integers libraries for OCaml...

-- Alain
-------------------
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] arbitrarily large integers
@ 2002-12-03  9:47 Yann Régis-Gianas
  0 siblings, 0 replies; 4+ messages in thread
From: Yann Régis-Gianas @ 2002-12-03  9:47 UTC (permalink / raw)
  To: caml-list

Le Mardi 3 Décembre 2002 08:40, Scott J. a écrit :
> Hi,

	Hello,

> 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

	Yes, it's possible : just use the nums library (documented in the
documentation at http://caml.inria.fr/ocaml/htmlman/manual036.html).

	An example :

#load "nums.cma";;

(* directly with Big_int ... *)
open Big_int

let fact n =
  let rec fact_ acu p =
    if p = 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_ = num_of_int

let big_fact n =
  let rec fact_ acu p =
    if p = 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-12-03 19:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-03  7:40 [Caml-list] arbitrarily large integers Scott J.
2002-12-03 13:00 ` Jean-Christophe Filliatre
2002-12-03 18:23 ` Alain.Frisch
2002-12-03  9:47 Yann Régis-Gianas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).