src/Pure/library.ML
changeset 8418 26eb0c4db5a5
parent 8043 0e4434d55df9
child 8806 a202293db3f6
equal deleted inserted replaced
8417:ae28c198e78d 8418:26eb0c4db5a5
     6 Basic library: functions, options, pairs, booleans, lists, integers,
     6 Basic library: functions, options, pairs, booleans, lists, integers,
     7 strings, lists as sets, association lists, generic tables, balanced
     7 strings, lists as sets, association lists, generic tables, balanced
     8 trees, orders, I/O and diagnostics, timing, misc.
     8 trees, orders, I/O and diagnostics, timing, misc.
     9 *)
     9 *)
    10 
    10 
    11 infix |> ~~ \ \\ ins ins_string ins_int orf andf prefix upto downto
    11 infix |> |>> |>>> ~~ \ \\ ins ins_string ins_int orf andf prefix upto downto
    12   mem mem_int mem_string union union_int union_string inter inter_int
    12   mem mem_int mem_string union union_int union_string inter inter_int
    13   inter_string subset subset_int subset_string;
    13   inter_string subset subset_int subset_string;
    14 
    14 
    15 infix 3 oo ooo oooo;
    15 infix 3 oo ooo oooo;
    16 
    16 
    20   val curry: ('a * 'b -> 'c) -> 'a -> 'b -> 'c
    20   val curry: ('a * 'b -> 'c) -> 'a -> 'b -> 'c
    21   val uncurry: ('a -> 'b -> 'c) -> 'a * 'b -> 'c
    21   val uncurry: ('a -> 'b -> 'c) -> 'a * 'b -> 'c
    22   val I: 'a -> 'a
    22   val I: 'a -> 'a
    23   val K: 'a -> 'b -> 'a
    23   val K: 'a -> 'b -> 'a
    24   val |> : 'a * ('a -> 'b) -> 'b
    24   val |> : 'a * ('a -> 'b) -> 'b
       
    25   val |>> : ('a * 'b) * ('a -> 'c) -> 'c * 'b
       
    26   val |>>> : ('a * 'b) * ('a -> 'c * 'd) -> 'c * ('b * 'd)
    25   val apl: 'a * ('a * 'b -> 'c) -> 'b -> 'c
    27   val apl: 'a * ('a * 'b -> 'c) -> 'b -> 'c
    26   val apr: ('a * 'b -> 'c) * 'b -> 'a -> 'c
    28   val apr: ('a * 'b -> 'c) * 'b -> 'a -> 'c
    27   val funpow: int -> ('a -> 'a) -> 'a -> 'a
    29   val funpow: int -> ('a -> 'a) -> 'a -> 'a
    28   val oo: ('a -> 'b) * ('c -> 'd -> 'a) -> 'c -> 'd -> 'b
    30   val oo: ('a -> 'b) * ('c -> 'd -> 'a) -> 'c -> 'd -> 'b
    29   val ooo: ('a -> 'b) * ('c -> 'd -> 'e -> 'a) -> 'c -> 'd -> 'e -> 'b
    31   val ooo: ('a -> 'b) * ('c -> 'd -> 'e -> 'a) -> 'c -> 'd -> 'e -> 'b
   270 fun I x = x;
   272 fun I x = x;
   271 fun K x y = x;
   273 fun K x y = x;
   272 
   274 
   273 (*reverse apply*)
   275 (*reverse apply*)
   274 fun (x |> f) = f x;
   276 fun (x |> f) = f x;
       
   277 fun ((x, y) |>> f) = (f x, y);
       
   278 fun ((x, y) |>>> f) = let val (x', z) = f x in (x', (y, z)) end;
   275 
   279 
   276 (*application of (infix) operator to its left or right argument*)
   280 (*application of (infix) operator to its left or right argument*)
   277 fun apl (x, f) y = f (x, y);
   281 fun apl (x, f) y = f (x, y);
   278 fun apr (f, y) x = f (x, y);
   282 fun apr (f, y) x = f (x, y);
   279 
   283