added nth_list;
authorwenzelm
Tue, 29 Nov 2005 23:00:03 +0100
changeset 18286 7273cf5085ed
parent 18285 83e92f9b32c4
child 18287 28efcdae34dc
added nth_list;
src/Pure/library.ML
--- a/src/Pure/library.ML	Tue Nov 29 22:52:19 2005 +0100
+++ b/src/Pure/library.ML	Tue Nov 29 23:00:03 2005 +0100
@@ -107,6 +107,7 @@
   val nth: 'a list -> int -> 'a
   val nth_update: int * 'a -> 'a list -> 'a list
   val nth_map: int -> ('a -> 'a) -> 'a list -> 'a list
+  val nth_list: 'a list list -> int -> 'a list
   val split_last: 'a list -> 'a list * 'a
   val find_index: ('a -> bool) -> 'a list -> int
   val find_index_eq: ''a -> ''a list -> int
@@ -563,7 +564,8 @@
   | nth_map n f (x :: xs) = x :: nth_map (n - 1) f xs
   | nth_map _ _ [] = raise Subscript;
 
-(*last element of a list*)
+fun nth_list xss i = nth xss i handle Subscript => [];
+
 val last_elem = List.last;
 
 (*rear decomposition*)