Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve pretty-printing #64

Closed
jstolarek opened this issue Feb 27, 2017 · 2 comments
Closed

Improve pretty-printing #64

jstolarek opened this issue Feb 27, 2017 · 2 comments

Comments

@jstolarek
Copy link
Owner

Pretty-printing for larger programs is far from "pretty":

Running examples/gauss.tml
val it = let n = 4
in let as = array(n, _)
   in set(as, 0, array(n, _)) ;; set(as, 1, array(n, _)) ;; set(as, 2, array(n, _)) ;; _ ;; set(get(as, 0), 0, 3.0) ;; set(get(as, 0), 1, -1.0) ;; _ ;; _ ;; set(get(as, 1), 0, 3.0) ;; set(get(as, 1), 1, -1.0) ;; _ ;; _ ;; set(get(as, 2), 0, 1.0) ;; set(get(as, 2), 1, 2.0) ;; _ ;; _ ;; _ ;; _ ;; _ ;; _ ;; let bs = _
                                                                                                                                                                                                                                                                                                                  in _ ;; _ ;; _ ;; _ ;; let gauss = (fun gauss a
                                                                                                                                                                                                                                                                                                                                                                b => let dia = ref 0
                                                                                                                                                                                                                                                                                                                                                                     in (while !dia < n do let row = ref (!dia + 1)
                                                                                                                                                                                                                                                                                                                                                                                           in (while !row < n do let tmp = (get(get(a, !row), !dia)) / (get(get(a, !dia), !dia))
                                                                                                                                                                                                                                                                                                                                                                                                                 in let col = ref (!dia + 1)
                                                                                                                                                                                                                                                                                                                                                                                                                    in (while !col < n do let x = get(get(a, !row), !col)
                                                                                                                                                                                                                                                                                                                                                                                                                                          in set(get(a, !row), !col, x - (tmp * (get(get(a, !dia), !col)))) ;; _) ;; _ ;; let b_row = _
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          in _ ;; row := !row + 1) ;; dia := !dia + 1) ;; _)
                                                                                                                                                                                                                                                                                                                                         in let xs = gauss
                                                                                                                                                                                                                                                                                                                                                     as
                                                                                                                                                                                                                                                                                                                                                     _
                                                                                                                                                                                                                                                                                                                                            in _ : trace((double * (double * (double * double))))

Need to do something about those indentations.

jstolarek added a commit that referenced this issue Mar 20, 2017
@jstolarek
Copy link
Owner Author

Reported example now pretty prints as:

Running ../../examples/gauss.tml
val it = let n = 4 in
let as = _ in
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
let bs = _ in
_ ;;
_ ;;
_ ;;
_ ;;
let as' = array(n, _) in
set(as', 0, array(n, _)) ;;
set(as', 1, array(n, _)) ;;
set(as', 2, array(n, _)) ;;
_ ;;
set(get(as', 0), 0, 3.0) ;;
set(get(as', 0), 1, -1.0) ;;
_ ;;
_ ;;
set(get(as', 1), 0, 3.0) ;;
set(get(as', 1), 1, -1.0) ;;
_ ;;
_ ;;
set(get(as', 2), 0, 1.0) ;;
set(get(as', 2), 1, 2.0) ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
_ ;;
let bs' = _ in
_ ;;
_ ;;
_ ;;
_ ;;
let gauss = (fun gauss a b =>
             let dia = ref 0 in
             (while !dia < n do
                let row = ref (!dia + 1) in
                (while !row < n do
                   let tmp = (get(get(a, !row), !dia)) / (get(get(a, !dia), !dia)) in
                   let col = ref (!dia + 1) in
                   (while !col < n do
                      let x = get(get(a, !row), !col) in
                      set(get(a, !row), !col, x - (tmp * (get(get(a, !dia), !col)))) ;;
                      _)
                   ;;
                   _ ;;
                   let b_row = _ in
                   _ ;; row := !row + 1)
                ;; dia := !dia + 1)
             ;; _) in
map (fun f x => gauss fst x _) Cons (_, Cons ((as', _), _)) : trace(reslist)

@rolyp
Copy link
Collaborator

rolyp commented Mar 21, 2017 via email

jstolarek added a commit that referenced this issue Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants