equal
deleted
inserted
replaced
42 val eq_snd: ('b * 'd -> bool) -> ('a * 'b) * ('c * 'd) -> bool |
42 val eq_snd: ('b * 'd -> bool) -> ('a * 'b) * ('c * 'd) -> bool |
43 val eq_pair: ('a * 'c -> bool) -> ('b * 'd -> bool) -> ('a * 'b) * ('c * 'd) -> bool |
43 val eq_pair: ('a * 'c -> bool) -> ('b * 'd -> bool) -> ('a * 'b) * ('c * 'd) -> bool |
44 val swap: 'a * 'b -> 'b * 'a |
44 val swap: 'a * 'b -> 'b * 'a |
45 val apfst: ('a -> 'b) -> 'a * 'c -> 'b * 'c |
45 val apfst: ('a -> 'b) -> 'a * 'c -> 'b * 'c |
46 val apsnd: ('a -> 'b) -> 'c * 'a -> 'c * 'b |
46 val apsnd: ('a -> 'b) -> 'c * 'a -> 'c * 'b |
47 val pairself: ('a -> 'b) -> 'a * 'a -> 'b * 'b |
47 val apply2: ('a -> 'b) -> 'a * 'a -> 'b * 'b |
48 |
48 |
49 (*booleans*) |
49 (*booleans*) |
50 val equal: ''a -> ''a -> bool |
50 val equal: ''a -> ''a -> bool |
51 val not_equal: ''a -> ''a -> bool |
51 val not_equal: ''a -> ''a -> bool |
52 val orf: ('a -> bool) * ('a -> bool) -> 'a -> bool |
52 val orf: ('a -> bool) * ('a -> bool) -> 'a -> bool |
281 |
281 |
282 fun swap (x, y) = (y, x); |
282 fun swap (x, y) = (y, x); |
283 |
283 |
284 fun apfst f (x, y) = (f x, y); |
284 fun apfst f (x, y) = (f x, y); |
285 fun apsnd f (x, y) = (x, f y); |
285 fun apsnd f (x, y) = (x, f y); |
286 fun pairself f (x, y) = (f x, f y); |
286 fun apply2 f (x, y) = (f x, f y); |
287 |
287 |
288 |
288 |
289 (* booleans *) |
289 (* booleans *) |
290 |
290 |
291 (*polymorphic equality*) |
291 (*polymorphic equality*) |
962 |
962 |
963 fun sort ord = mergesort false ord; |
963 fun sort ord = mergesort false ord; |
964 fun sort_distinct ord = mergesort true ord; |
964 fun sort_distinct ord = mergesort true ord; |
965 |
965 |
966 val sort_strings = sort string_ord; |
966 val sort_strings = sort string_ord; |
967 fun sort_wrt key xs = sort (string_ord o pairself key) xs; |
967 fun sort_wrt key xs = sort (string_ord o apply2 key) xs; |
968 |
968 |
969 |
969 |
970 (* items tagged by integer index *) |
970 (* items tagged by integer index *) |
971 |
971 |
972 (*insert tags*) |
972 (*insert tags*) |
979 | untag_list ((k, x) :: (rest as (k', x') :: _)) = |
979 | untag_list ((k, x) :: (rest as (k', x') :: _)) = |
980 if k = k' then untag_list rest |
980 if k = k' then untag_list rest |
981 else x :: untag_list rest; |
981 else x :: untag_list rest; |
982 |
982 |
983 (*return list elements in original order*) |
983 (*return list elements in original order*) |
984 fun order_list list = untag_list (sort (int_ord o pairself fst) list); |
984 fun order_list list = untag_list (sort (int_ord o apply2 fst) list); |
985 |
985 |
986 |
986 |
987 |
987 |
988 (** random numbers **) |
988 (** random numbers **) |
989 |
989 |