| `Cons ( x', xs' ) -> update_const xs (force xs'); x'

+ (** Update the [k]th element of a self-adjusting list to insert a value [x]. *)

+ if k < 0 then invalid_arg "insert";

+ let rec insert k xs = match force xs with

+ | `Cons ( _, xs ) when k > 0 -> insert (k - 1) xs

+ | `Nil when k > 0 -> failwith "insert"

+ | `Cons _ | `Nil -> push x xs

+ (** Update the [k]th element of a self-adjusting list to remove a value and return it. *)

+ if k < 0 then invalid_arg "remove";

+ let rec remove k xs = match force xs with

+ | `Cons ( _, xs ) when k > 0 -> remove (k - 1) xs

+ | `Nil -> failwith "remove"

(** Create memoizing constructor that concatenate two self-adjusting lists. *)

memo2 (module L) (module L) begin fun append xs ys -> match force xs with

# Source/Adapton/Signatures.ml

val of_list : data list -> t

val push : data -> t -> unit

+ val insert : int -> data -> t -> unit

+ val remove : int -> t -> data

val memo_append : t -> t -> t

val memo_filter : (data -> bool) -> (t -> t)

# Test/TestAdapton/TestSAList.ml

- let rec insert k xs' = match I.force xs' with

- | `Cons ( x', xs' ) when k > 0 -> insert (pred k) xs'

- let rec delete k xs' = match I.force xs' with

- | `Cons ( x', xs' ) when k > 0 -> delete (pred k) xs'

- | `Cons _ -> ignore (I.pop xs')

- | `Nil -> failwith "delete"

+ ignore (I.remove k xs');