scicloj / wolframite

An interface between Clojure and Wolfram Language (the language of Mathematica)
https://scicloj.github.io/wolframite/
Mozilla Public License 2.0
56 stars 2 forks source link

Clojure code inside w/fn is not evaluated #106

Closed holyjak closed 2 months ago

holyjak commented 2 months ago

I'd like this to work

(def header->idx {"start_lng" 1, ..})

(wl/eval (-> (w/Map (w/fn [row] [(w/Part row (header->idx "start_lng")) 
                                 (w/Part row (header->idx "start_lat"))])
                    'rows)
             (w/Part (w/Range 1 3))))

to work but it fails with Unsupported symbol / unknown alias: .... Passed: header->idx. I would want the (header->idx "start_lng") to be evaluated on Clojure side, before it is sent to Wolfram.

This is related to the problem that I have to write

(wl/->wl (w/Map (w/fn [row] (Internal/StringToMReal row)) ;; FIXME does not work ,but the above thus
                    ["123"]))

whilst I would have preferred ... (w/fn [row] '(Internal/StringToMReal row)) ..., i.e. with a quote inside the body, since otherwise my IDE will complain about an uknown symbol. (Notice that the w/fn macro leaves its body un-evaluated, so if I add the quote, I do not prevent evaluation but will end up with the raw input wrapped in (quote ...) - as if I did double quoting in clj itself: ''(whatver...).