Ignore:
Timestamp:
May 19, 2011, 4:03:04 PM (10 years ago)
Author:
ayache
Message:

32 and 16 bits operations support in D2.2/8051

Location:
Deliverables/D2.2/8051/src/utilities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/utilities/miscPottier.ml

    r740 r818  
     1
     2let rec map3 f al bl cl =
     3  let f' ((a, b), c) = f a b c in
     4  List.map f' (List.combine (List.combine al bl) cl)
    15
    26let rec max_list = function
     
    48  | [a] -> a
    59  | a :: l -> max a (max_list l)
     10
     11let rec reduce l1 l2 = match l1, l2 with
     12  | [], _ -> (([], []), ([], l2))
     13  | _, [] -> (([], l1), ([], []))
     14  | a :: l1, b :: l2 ->
     15    let ((common1, rest1), (common2, rest2)) = reduce l1 l2 in
     16    ((a :: common1, rest1), (b :: common2, rest2))
    617
    718let pow a b =
     
    4354
    4455let foldi f a l = foldi_from_until 0 (List.length l) f a l
     56
     57let pos e l =
     58  let f i res e' = if e' = e then Some i else res in
     59  match foldi f None l with
     60    | None -> raise Not_found
     61    | Some i -> i
    4562
    4663let iteri f l =
  • Deliverables/D2.2/8051/src/utilities/miscPottier.mli

    r740 r818  
    11
    22(** This module provides some additional functions on lists or arithmetics. *)
     3
     4(* raises Not_found *)
     5val pos : 'a -> 'a list -> int
     6
     7val reduce : 'a list -> 'b list -> ('a list * 'a list) * ('b list * 'b list)
     8
     9(* raise Failure "MiscPottier.map3" if the list arguments are not of the same
     10   size. *)
     11val map3 : ('a -> 'b -> 'c -> 'd) -> 'a list -> 'b list -> 'c list -> 'd list
    312
    413val max_list : 'a list -> 'a
     
    2332(* [split l i] splits the list [l] in two lists: one with the elements
    2433   up until the [i]th (exclusive) and one with the rest. *)
    25 
    2634val split: 'a list -> int -> ('a list * 'a list)
    2735
     
    2937   element. Raises Invalid_argument "MiscPottier.split_last" if the list is
    3038   empty. *)
    31 
    3239val split_last : 'a list -> ('a list * 'a)
    3340
  • Deliverables/D2.2/8051/src/utilities/stringSig.mli

    r486 r818  
    2020  end
    2121
     22  val make_unique : Set.t -> (string -> string)
     23
    2224end
  • Deliverables/D2.2/8051/src/utilities/stringTools.ml

    r486 r818  
    1717  type universe = { prefix : string ; mutable next : int }
    1818
    19   let added_prefix = "_"
     19  let added_suffix = "_"
    2020
    2121  let is_prefix prefix s =
     
    2929  let fresh_prefix set prefix =
    3030    let rec aux prefix =
    31       if has_prefix set prefix then aux (added_prefix ^ prefix)
     31      if has_prefix set prefix then aux (prefix ^ added_suffix)
    3232      else prefix in
    3333    aux prefix
     
    4242
    4343end
     44
     45let make_unique set =
     46  let set_ref = ref set in
     47  let unique s =
     48    let res = Gen.fresh_prefix !set_ref s in
     49    set_ref := Set.add res !set_ref ;
     50    res in
     51  unique
Note: See TracChangeset for help on using the changeset viewer.