Kaynağa Gözat

make double accept func as arguments

plato 5 yıl önce
ebeveyn
işleme
0f38f73ceb
2 değiştirilmiş dosya ile 12 ekleme ve 3 silme
  1. 10 0
      lisp/core.rs
  2. 2 3
      lisp/examples/mint2.lisp

+ 10 - 0
lisp/core.rs

@@ -505,6 +505,16 @@ fn scalar_square(a: MalArgs) -> MalRet {
 
 fn scalar_double(a: MalArgs) -> MalRet {
     match a[0].clone() {
+        Func(_, _) => {
+            if let Vector(ref values, _) = r oua[0].apply(vec![]).unwrap() {
+                if let ZKScalar(a0) = values[0] {
+                    a0.double();
+                    Ok(ZKScalar(a0))
+                } else {
+                    error(&format!("scalar double expect (zkscalar or string) found \n {:?}", a).to_string())
+                }
+            } 
+        }
         ZKScalar(a0) => {
             let z0 = a0.clone();
             Ok(ZKScalar(z0.double()))

+ 2 - 3
lisp/examples/mint2.lisp

@@ -279,13 +279,12 @@
     (def! value-alloc (alloc "value-alloc" value))
     (def! values-bit (unpack-bits value))
     (def! acc 0)
-    (def! digit (scalar::one))    
+    (def! digit scalar::one)    
     (def! value-result (scalar::zero))
-    (println (count values-bit))
     (dotimes 64 (
         (rangeproof-alloc (nth values-bit acc))
         (def! digit (double digit))
-        (def! value-result (add bit))
+        (println digit)
         (def! acc (i+ acc 1))
     ))
     ;; todo add last enforce