dtlc

dependently-typed lambda calculus toy
git clone git://git.rr3.xyz/dtlc
Log | Files | Refs | README | LICENSE

util.ml (615B)


      1 let impossible
      2 : 'a. string -> 'a
      3 = fun reason -> failwith ("impossible: " ^ reason)
      4 
      5 let no_impl
      6 : 'a. string -> 'a
      7 = fun feature -> failwith ("no impl: " ^ feature)
      8 
      9 (* For creating uninitialized arrays *)
     10 let garbage: 'a. 'a = Obj.magic 0
     11 
     12 (* For some reason this isn't in the standard Array module... *)
     13 let fold_left2
     14 : 'acc 'a 'b. ('acc -> 'a -> 'b -> 'acc) -> 'acc -> 'a array -> 'b array -> 'acc
     15 = fun f acc xs ys ->
     16 	begin if Array.length xs <> Array.length ys then
     17 		invalid_arg "Util.fold_left2"
     18 	end;
     19 	let acc = ref acc in
     20 	for i = 0 to Array.length xs - 1 do
     21 		acc := f !acc xs.(i) ys.(i)
     22 	done;
     23 	!acc