~ubuntu-branches/ubuntu/hardy/ocaml-doc/hardy

« back to all changes in this revision

Viewing changes to examples/asl/prel.ml

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2007-09-08 01:49:22 UTC
  • mfrom: (0.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070908014922-lvihyehz0ndq7suu
Tags: 3.10-1
* New upstream release.
* Removed camlp4 documentation since it is not up-to-date.
* Updated to standards version 3.7.2, no changes needed.
* Updated my email address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
let index a =
2
 
  let rec index_rec i = function
3
 
    | []  -> raise Not_found
4
 
    | b :: l -> if a = b then i else index_rec (succ i) l in
5
 
  index_rec 0;;
6
 
 
7
 
let flat l = List.fold_left ( @) [] l;;
8
 
 
9
 
let subtract f l =
10
 
 match f, l with
11
 
 | f, [] -> f
12
 
 | f, e ->
13
 
    let rec subtract_e = function
14
 
      | [] -> []
15
 
      | elem :: l ->
16
 
         if List.mem elem e then subtract_e l else elem :: subtract_e l in
17
 
 subtract_e f
18
 
;;
19
 
 
20
 
let rec make_set = function
21
 
  | []  -> []
22
 
  | x :: l -> if List.mem x l then make_set l else x :: make_set l
23
 
;;
24
 
 
25
 
let except_nth =
26
 
  let rec except_n_l n = function
27
 
    | [] -> []
28
 
    | (elem :: l) -> if n = 0 then l else elem :: except_n_l (n - 1) l in
29
 
  fun l n -> except_n_l n l
30
 
;;
31
 
 
32