Ignore:
Timestamp:
Mar 2, 2011, 3:27:41 PM (9 years ago)
Author:
ayache
Message:

Update of D2.2 from Paris.

File:
1 edited

Legend:

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

    r486 r619  
    3232  aux 0 l
    3333
     34let rec last = function
     35  | [] -> raise Not_found
     36  | [a] -> a
     37  | _ :: l -> last l
     38
    3439(* [split a i] splits the list a in two lists: one with the elements
    3540   up until the [i]th (exclusive) and one with the rest. *)
     
    4045    let (l1, l2) = split (List.tl l) (i-1) in
    4146    ((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
     52let split_last l = match split l ((List.length l) - 1) with
     53  | l', last :: _ -> (l', last)
     54  | _ -> raise (Invalid_argument "MiscPottier.split_last")
    4255
    4356let rec update_list_assoc a b = function
Note: See TracChangeset for help on using the changeset viewer.