Source

calcoq / util.ml

Full commit
let ( @@ ) f x = f x
let ( $ ) g f x = g (f x)
let ( +> ) x f = f x
let id x = x

let slist ?(delim="; ") f l = (String.concat delim @@ List.map f l)

let string1 c = String.make 1 c

let char_concat = slist ~delim:"" (String.make 1)
let cs_string s =
  let rec iter store i =
    if i < 0 then store
    else iter (s.[i]::store) (i-1)
  in
  iter [] (String.length s - 1)

let infile filename f =
  let ch = open_in filename in
  try
    let y = f ch in
    close_in ch; y
  with
  | e -> close_in ch; raise e