plato пре 5 година
родитељ
комит
2aa1e1c939
2 измењених фајлова са 7 додато и 7 уклоњено
  1. 6 6
      lisp/examples/macro-test.lisp
  2. 1 1
      lisp/lisp.rs

+ 6 - 6
lisp/examples/macro-test.lisp

@@ -239,10 +239,10 @@
         ((scalar::one xl) (~cur-mimc-const cs::one))
         ((scalar::one xl) (~cur-mimc-const cs::one))
         (scalar::one ~tmp-xl)
-    )        
-    (if (= acc 321)
-        `(def! ~xl-new-value (alloc ~xl-new-value (+ (* ~tmp-xl (+ ~cur-mimc-const ~xl)) ~xr)))    
-        `(def! ~xl-new-value (alloc-input ~xl-new-value (+ (* ~tmp-xl (+ ~cur-mimc-const ~xl)) ~xr)))    
+    )   
+    `(if (= ~acc 321)        
+        (def! ~xl-new-value (alloc-input ~xl-new-value (+ (* ~tmp-xl (+ ~cur-mimc-const ~xl)) ~xr)))
+        (def! ~xl-new-value (alloc ~xl-new-value (+ (* ~tmp-xl (+ ~cur-mimc-const ~xl)) ~xr)))
     )
     `(enforce 
         (scalar::one ~tmp-xl)
@@ -255,9 +255,9 @@
     (def! xr (alloc "xr" right))
     (def! acc 0)
     (dotimes 322 (
-        (println (mimc-macro xl xr acc))
-        (def! acc (i+ acc 1))
         (println acc)
+        (println (mimc-macro xl xr acc))
+        (def! acc (i+ acc 1))        
     ))
 )))
 

+ 1 - 1
lisp/lisp.rs

@@ -291,7 +291,7 @@ fn eval(mut ast: MalVal, mut env: Env) -> MalRet {
                     Sym(ref a0sym) if a0sym == "dotimes" => {
                         match eval(l[1].clone(), env.clone())? {
                             MalVal::Int(v) => {
-                                for _i in 1..v {
+                                for _i in 0..v {
                                     eval(l[2].clone(), env.clone())?;
                                 }
                                 Ok(Nil)