src/Pure/General/vector.ML
author wenzelm
Sun, 31 Dec 2023 12:40:10 +0100
changeset 79404 cb19148c0b95
parent 77853 5286dae99de3
permissions -rw-r--r--
tuned comments;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
77846
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/General/vector.ML
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
     3
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
     4
Additional operations for structure Vector, following Isabelle/ML conventions.
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
     5
*)
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
     6
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
     7
signature VECTOR =
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
     8
sig
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
     9
  include VECTOR
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    10
  val nth: 'a vector -> int -> 'a
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    11
  val forall: ('a -> bool) -> 'a vector -> bool
77853
5286dae99de3 more operations;
wenzelm
parents: 77846
diff changeset
    12
  val member: ('a * 'a -> bool) -> 'a vector -> 'a -> bool
77846
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    13
  val fold: ('a -> 'b -> 'b) -> 'a vector -> 'b -> 'b
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    14
  val fold_rev: ('a -> 'b -> 'b) -> 'a vector -> 'b -> 'b
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    15
end;
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    16
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    17
structure Vector: VECTOR =
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    18
struct
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    19
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    20
open Vector;
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    21
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    22
fun nth vec i = sub (vec, i);
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    23
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    24
val forall = all;
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    25
77853
5286dae99de3 more operations;
wenzelm
parents: 77846
diff changeset
    26
fun member eq vec x = exists (fn y => eq (x, y)) vec;
5286dae99de3 more operations;
wenzelm
parents: 77846
diff changeset
    27
77846
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    28
fun fold f vec x = foldl (fn (a, b) => f a b) x vec;
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    29
fun fold_rev f vec x = foldr (fn (a, b) => f a b) x vec;
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    30
5ba68d3bd741 more operations, following Isabelle/ML conventions;
wenzelm
parents:
diff changeset
    31
end;