Module of module types for OrderedType,ComparableType,Printable,Serializable,Discrete...
[ocaml.git] / testasmcomp / integr.cmm
blob481dd7587df3d6142c29c2f60ec633d511ca86e2
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                           Objective Caml                            *)
4 (*                                                                     *)
5 (*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         *)
6 (*                                                                     *)
7 (*  Copyright 1996 Institut National de Recherche en Informatique et   *)
8 (*  en Automatique.  All rights reserved.  This file is distributed    *)
9 (*  under the terms of the Q Public License version 1.0.               *)
10 (*                                                                     *)
11 (***********************************************************************)
13 (* $Id$ *)
15 (function "square" (x: float)
16    ( *f x x))
18 (function "integr" (f: addr low: float high: float n: int)
19   (let (h (/f (-f high low) (floatofint n))
20         x low
21         s 0.0
22         i n)
23     (while (> i 0)
24       (assign s (+f s (app f x float)))
25       (assign x (+f x h))
26       (assign i (- i 1)))
27     ( *f s h)))
29 (function "test" (n: int)
30   (app "integr" "square" 0.0 1.0 n float))