(* %use "Distributions/implode_type.fsh" ;; *) (* implode_type : [[a]] -> [a] removes the (outermost) type boundary in an array of arrays. *) let reverse_shape = folddim zerodim snocdim ;; let implode_type_sh xsh = extendShape2 xsh (zeroShape xsh) ;; let implode_type_pr (y:var b) (x:var a) = primrec g (fun y -> fun (x:var a) -> y:= get x) (numdim #x) y x where g n h (y: var b) (x:var a) = for 0 <= i < lendim #x do h sub(y,i) sub(x,i) done ;; let implode_type = proc2fun implode_type_pr implode_type_sh ;; let explode_type_sh k xsh = primrec f (zerodim xsh) k where f n x = extendShape2 x (succdim (lendim (zeroShape x)) (zerodim (preddim (zeroShape x)))) ;; let explode_type_pr y x = let pr ndx yi = yi := multi_sub ndx x in idoall pr y ;; let explode_type k = proc2fun explode_type_pr (explode_type_sh k) ;;