Changeset 619 for Deliverables/D2.2/8051/src/utilities
- Timestamp:
- Mar 2, 2011, 3:27:41 PM (10 years ago)
- Location:
- Deliverables/D2.2/8051/src/utilities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Deliverables/D2.2/8051/src/utilities/miscPottier.ml
r486 r619 32 32 aux 0 l 33 33 34 let rec last = function 35 | [] -> raise Not_found 36 | [a] -> a 37 | _ :: l -> last l 38 34 39 (* [split a i] splits the list a in two lists: one with the elements 35 40 up until the [i]th (exclusive) and one with the rest. *) … … 40 45 let (l1, l2) = split (List.tl l) (i-1) in 41 46 ((List.hd l) :: l1, l2) 47 48 (* [split_last l] returns the list [l] without its last element and its last 49 element. Raises Invalid_argument "MiscPottier.split_last" if the list is 50 empty. *) 51 52 let split_last l = match split l ((List.length l) - 1) with 53 | l', last :: _ -> (l', last) 54 | _ -> raise (Invalid_argument "MiscPottier.split_last") 42 55 43 56 let rec update_list_assoc a b = function -
Deliverables/D2.2/8051/src/utilities/miscPottier.mli
r486 r619 6 6 val index_of : 'a -> 'a list -> int 7 7 8 val foldi : (int -> 'a -> 'b -> 'a) -> 'a -> 'b list -> 'a8 val foldi : (int -> 'a -> 'b -> 'a) -> 'a -> 'b list -> 'a 9 9 10 val iteri : (int -> 'a -> unit) -> 'a list -> unit10 val iteri : (int -> 'a -> unit) -> 'a list -> unit 11 11 12 val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list12 val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list 13 13 14 (* [split a i] splits the list a in two lists: one with the elements 14 (* Raises Not_found if the list is empty. *) 15 val last : 'a list -> 'a 16 17 (* [split l i] splits the list [l] in two lists: one with the elements 15 18 up until the [i]th (exclusive) and one with the rest. *) 16 19 17 20 val split: 'a list -> int -> ('a list * 'a list) 21 22 (* [split_last l] returns the list [l] without its last element and its last 23 element. Raises Invalid_argument "MiscPottier.split_last" if the list is 24 empty. *) 25 26 val split_last : 'a list -> ('a list * 'a) 18 27 19 28 val update_list_assoc: 'a -> 'b -> ('a * 'b) list -> ('a * 'b) list
Note: See TracChangeset
for help on using the changeset viewer.