Signed-off-by: Matthias Goergens <[email protected]>

 stdext/listext.ml  |  4 ++++
 stdext/listext.mli |  1 +
 2 files changed, 5 insertions(+), 0 deletions(-)


# HG changeset patch
# User Matthias Goergens <[email protected]>
# Date 1274194687 -3600
# Node ID 3d335a63fbc8bae4f18cddc58544777e6c2b329d
# Parent  5ed655dae285df1e9a4beec99e2f3308f56830d7
The module stdext/Listext got a safe_head function that wraps hd in an option type.

Signed-off-by: Matthias Goergens <[email protected]>

diff --git a/stdext/listext.ml b/stdext/listext.ml
--- a/stdext/listext.ml
+++ b/stdext/listext.ml
@@ -193,6 +193,10 @@ let rec tails = function
     | [] -> [[]]
     | (_::xs) as l -> l :: tails xs
 
+let safe_hd = function
+	| a::_ -> Some a
+	| [] -> None
+
 let rec replace_assoc key new_value = function
 	| [] -> []
 	| (k, _) as p :: tl ->
diff --git a/stdext/listext.mli b/stdext/listext.mli
--- a/stdext/listext.mli
+++ b/stdext/listext.mli
@@ -176,6 +176,7 @@ module List :
     val take : int -> 'a list -> 'a list
 	
     val tails : 'a list -> ('a list) list
+	val safe_hd : 'a list -> 'a option
 
 	(** Replace the value belonging to a key in an association list. *)
 	val replace_assoc : 'a -> 'b -> ('a * 'b) list -> ('a * 'b) list
_______________________________________________
xen-api mailing list
[email protected]
http://lists.xensource.com/mailman/listinfo/xen-api

Reply via email to