NEXT ·  UP ·  PREVIOUS ·  CONTENTS ·  INDEX

The List structure

Many of the functions which we defined earlier are in the library structure List. For convenience we have used the same names for functions as the List structure does and our functions behave in the same way as the corresponding library functions. Thus for example, where we defined hd and tl the library provides List.hd and List.tl and these raise the exception List.Empty when applied to empty lists. Similarly the List structure provides List.@,List.concat, List.drop, List.foldl, List.foldr, List.last, List.length, List.mapPartial, List.nth, List.null, List.rev, List.revAppend and List.take. In addition to these functions List structure also provides others listed below. Most of these are almost self-explanatory when considering the type of the function together with its descriptive identifier.

  List.all : ('a -> bool) -> 'a list -> bool
  List.exists : ('a -> bool) -> 'a list -> bool
  List.filter : ('a -> bool) -> 'a list -> 'a list
  List.find : ('a -> bool) -> 'a list -> 'a option
  List.partition : ('a -> bool) -> 'a list -> 'a list * 'a list
  List.tabulate : int * (int -> 'a) -> 'a list


NEXT ·  UP ·  PREVIOUS ·  CONTENTS ·  INDEX