wisp
 
(Arne Babenhauserheide)
2015-08-04: nicer code (less lines, clearer structure, stick to 72 characters

nicer code (less lines, clearer structure, stick to 72 characters per line)

diff --git a/examples/cholesky.w b/examples/cholesky.w
--- a/examples/cholesky.w
+++ b/examples/cholesky.w
@@ -18,32 +18,26 @@ define : matrrix-set! X u v val
 
 
 define : cholesky! a
-   . "Modifies the square matirx a to contain the its cholesky decomposition.
+  . "Modifies the square matirx a to contain its cholesky decomposition.
 
 a is represented as list of lists."
-   let : : n : length a
-     loop
-       : for i : up-from 1 : to n
-       loop
-         : for j : up-from 1 : to i
-         let 
-           : sum : matrix-ref a i j
-           when (>= j 1)
-             loop
-               : for k : up-from 1 : to (- j 1)
-               set! sum 
-                 - sum 
-                   * (matrix-ref a i k) (matrix-ref a j k)
-           cond
-             : > i j ; lower triangle
-               matrix-set! a i j
-                 / sum : matrix-ref a j j
-               . a
-             : > sum 0 ; diagonal element
-               matrix-set! a i i : sqrt sum
-               . a
-             else
-               throw 'matrix-numerically-not-symmetric-positive-definite
+  let : : n : length a
+    loop : : for i : up-from 1 : to n
+      loop : : for j : up-from 1 : to i
+        let : : sum : matrix-ref a i j
+          when (>= j 1)
+            loop : : for k : up-from 1 : to {j - 1}
+              set! sum : - sum : * (matrix-ref a i k) (matrix-ref a j k)
+          cond
+            : > i j ; lower triangle
+              matrix-set! a i j
+                / sum : matrix-ref a j j
+              . a
+            : > sum 0 ; diagonal element
+              matrix-set! a i i : sqrt sum
+              . a
+            else
+              throw 'matrix-numerically-not-symmetric-positive-definite
 
 
 define : main args