~subsetpark/jnj

cde8a6740631ccd75751624061fc9becc635a502 — Zach Smith 2 months ago cab71b9 master
j-value -> j-array
4 files changed, 19 insertions(+), 18 deletions(-)

M README.md
M jnj.janet
M test/j.janet
M test/jnjc.janet
M README.md => README.md +4 -4
@@ 126,7 126,7 @@ repl:3:> (j "+/" _)

## jnj

[eval](#eval), [eval*](#eval-1), [from-j-value](#from-j-value), [j](#j), [j*](#j-1), [j-engine](#j-engine), [jnj-primitives/init](#jnj-primitivesinit), [let-j](#let-j), [let-j*](#let-j-1), [to-j-array](#to-j-array)
[eval](#eval), [eval*](#eval-1), [from-j-array](#from-j-array), [j](#j), [j*](#j-1), [j-engine](#j-engine), [jnj-primitives/init](#jnj-primitivesinit), [let-j](#let-j), [let-j*](#let-j-1), [to-j-array](#to-j-array)

## eval



@@ 155,15 155,15 @@ into a tuple matrix.

[2]: jnj.janet#L106

## from-j-value
## from-j-array

**function**  | [source][3]

```janet
(from-j-value res)
(from-j-array res)
```

Turn a j-value abstract type result into a Janet term of the appropriate shape:
Turn a j-array abstract type result into a Janet term of the appropriate shape:
- a string
- a scalar value
- a matrix of nested tuples

M jnj.janet => jnj.janet +5 -4
@@ 108,9 108,10 @@
    (intern-and-do-in locale je verb args)
    (getm-in locale je (result-sym locale))))

(defn from-j-value
(defn from-j-array
  ``
  Turn a j-value abstract type result into a Janet term of the appropriate shape:
  Turn a J Array abstract type result into a Janet term of the appropriate
  shape:
  - a string
  - a scalar value
  - a matrix of nested tuples


@@ 136,7 137,7 @@
          args (tuple/slice body 1)]
      (intern-and-do-in locale je verb args)
      (-> (getm-in locale je res-sym)
          (from-j-value)))))
          (from-j-array)))))

(defmacro let-j*
  ````


@@ 213,7 214,7 @@
  [je verb & args]

  (let [res (eval* je verb ;args)]
    (from-j-value res)))
    (from-j-array res)))

(defn to-j-array
  ```

M test/j.janet => test/j.janet +9 -9
@@ 19,7 19,7 @@
    (is (== (values ja) (values (unmarshal (marshal ja)))) "Marshal and unmarshal")
    (when array?
      (is (== expected-values (jnj-primitives/values ja)) "to-array")
      (is (== matrix-form (jnj/from-j-value ja)) "to-matrix"))))
      (is (== matrix-form (jnj/from-j-array ja)) "to-matrix"))))


(defmacro with-j


@@ 90,20 90,20 @@
               ("#" arglist))]
    (is (= 2 resp))))

(deftest to-j-value-test
  (let [j-a (jnj/to-j-value @[])]
(deftest to-j-array-test
  (let [j-a (jnj/to-j-array @[])]
    (test-array j-a 0 true 1 [0] [])))

(deftest to-j-value-ints-test
  (let [j-a (jnj/to-j-value @[1 2 3])]
(deftest to-j-array-ints-test
  (let [j-a (jnj/to-j-array @[1 2 3])]
    (test-array j-a 3 true 1 [3] [1 2 3])))

(deftest to-j-value-ints-tuple-test
  (let [j-a (jnj/to-j-value [1 2 3])]
(deftest to-j-array-ints-tuple-test
  (let [j-a (jnj/to-j-array [1 2 3])]
    (test-array j-a 3 true 1 [3] [1 2 3])))

(deftest to-j-value-matrix-test
  (let [j-a (jnj/to-j-value [[1 2 3]
(deftest to-j-array-matrix-test
  (let [j-a (jnj/to-j-array [[1 2 3]
                             [3 4 5]])]
    (test-array j-a 6 true 2 [2 3] [1 2 3 3 4 5] [[1 2 3] [3 4 5]])))


M test/jnjc.janet => test/jnjc.janet +1 -1
@@ 19,7 19,7 @@
    (is (== (values ja) (values (unmarshal (marshal ja)))) "Marshal and unmarshal")
    (when array?
      (is (== expected-values (jnj-primitives/values ja)) "to-array")
      (is (== matrix-form (jnj/from-j-value ja)) "to-matrix"))))
      (is (== matrix-form (jnj/from-j-array ja)) "to-matrix"))))

(defmacro with-j
  [& body]