Markus Mottl avatar Markus Mottl committed f48d51a

Cleaned up toplevel printing

Comments (0)

Files changed (3)

lib/install_printers.ml

 let printers =
   [
-    "Lacaml.Io.pp_top_rfvec";
-    "Lacaml.Io.pp_top_rcvec";
-    "Lacaml.Io.pp_top_rivec";
-    "Lacaml.Io.pp_top_fmat";
-    "Lacaml.Io.pp_top_cmat";
-    "Lacaml.Io.pp_top_imat";
+    "Lacaml.Io.Toplevel.pp_rfvec";
+    "Lacaml.Io.Toplevel.pp_rcvec";
+    "Lacaml.Io.Toplevel.pp_rivec";
+    "Lacaml.Io.Toplevel.pp_fmat";
+    "Lacaml.Io.Toplevel.pp_cmat";
+    "Lacaml.Io.Toplevel.pp_imat";
   ]
 
 let eval_string
 
 (* Good pretty-printers for toplevels *)
 
-(* Vectors *)
+module Toplevel = struct
+  (* Vectors *)
 
-let pp_labeled_col ppf c = if c > 0 then fprintf ppf "C%d" c
-let pp_labeled_row ppf r = if r > 0 then fprintf ppf "R%d" r
+  let pp_labeled_col ppf c = if c > 0 then fprintf ppf "C%d" c
+  let pp_labeled_row ppf r = if r > 0 then fprintf ppf "R%d" r
 
-let gen_pp_top_vec pp_el ppf vec =
-  pp_mat_gen ~pp_left:pp_labeled_row pp_el ppf (from_col_vec vec)
+  let gen_pp_vec pp_el ppf vec =
+    pp_mat_gen ~pp_left:pp_labeled_row pp_el ppf (from_col_vec vec)
 
-let pp_top_fvec ppf vec = gen_pp_top_vec pp_float_el ppf vec
-let pp_top_cvec ppf vec = gen_pp_top_vec pp_complex_el ppf vec
-let pp_top_ivec ppf vec = gen_pp_top_vec pp_int32_el ppf vec
+  let pp_fvec ppf vec = gen_pp_vec pp_float_el ppf vec
+  let pp_cvec ppf vec = gen_pp_vec pp_complex_el ppf vec
+  let pp_ivec ppf vec = gen_pp_vec pp_int32_el ppf vec
 
-let gen_pp_top_rvec pp_el ppf vec =
-  pp_mat_gen ~pp_head:pp_labeled_row pp_el ppf (from_row_vec vec)
+  let gen_pp_rvec pp_el ppf vec =
+    pp_mat_gen ~pp_head:pp_labeled_row pp_el ppf (from_row_vec vec)
 
-let pp_top_rfvec ppf vec = gen_pp_top_rvec pp_float_el ppf vec
-let pp_top_rcvec ppf vec = gen_pp_top_rvec pp_complex_el ppf vec
-let pp_top_rivec ppf vec = gen_pp_top_rvec pp_int32_el ppf vec
+  let pp_rfvec ppf vec = gen_pp_rvec pp_float_el ppf vec
+  let pp_rcvec ppf vec = gen_pp_rvec pp_complex_el ppf vec
+  let pp_rivec ppf vec = gen_pp_rvec pp_int32_el ppf vec
 
-(* Matrices *)
+  (* Matrices *)
 
-let gen_pp_top_mat pp_el ppf mat =
-  pp_mat_gen ~pp_head:pp_labeled_col ~pp_left:pp_labeled_row pp_el ppf mat
+  let gen_pp_mat pp_el ppf mat =
+    pp_mat_gen ~pp_head:pp_labeled_col ~pp_left:pp_labeled_row pp_el ppf mat
 
-let pp_top_fmat ppf mat = gen_pp_top_mat pp_float_el ppf mat
-let pp_top_cmat ppf mat = gen_pp_top_mat pp_complex_el ppf mat
-let pp_top_imat ppf mat = gen_pp_top_mat pp_int32_el ppf mat
+  let pp_fmat ppf mat = gen_pp_mat pp_float_el ppf mat
+  let pp_cmat ppf mat = gen_pp_mat pp_complex_el ppf mat
+  let pp_imat ppf mat = gen_pp_mat pp_int32_el ppf mat
+
+  let lsc n = Context.set_dim_defaults (Some (Context.create n))
+end
 (** These pretty-printers will use index labels for easier identification
     of rows and columns. *)
 
-val pp_top_fvec : (float, 'elt) pp_vec
-val pp_top_cvec : (Complex.t, 'elt) pp_vec
-val pp_top_ivec : (int32, 'elt) pp_vec
-val pp_top_rfvec : (float, 'elt) pp_vec
-val pp_top_rcvec : (Complex.t, 'elt) pp_vec
-val pp_top_rivec : (int32, 'elt) pp_vec
+module Toplevel : sig
+  val lsc : int -> unit
+  (* Shortcut for setting both the horizontal and vertical context. *)
 
-val pp_top_fmat : (float, 'elt) pp_mat
-val pp_top_cmat : (Complex.t, 'elt) pp_mat
-val pp_top_imat : (int32, 'elt) pp_mat
+  val pp_fvec : (float, 'elt) pp_vec
+  val pp_cvec : (Complex.t, 'elt) pp_vec
+  val pp_ivec : (int32, 'elt) pp_vec
+  val pp_rfvec : (float, 'elt) pp_vec
+  val pp_rcvec : (Complex.t, 'elt) pp_vec
+  val pp_rivec : (int32, 'elt) pp_vec
+
+  val pp_fmat : (float, 'elt) pp_mat
+  val pp_cmat : (Complex.t, 'elt) pp_mat
+  val pp_imat : (int32, 'elt) pp_mat
+end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.