infix icon indicating copy to clipboard operation
infix copied to clipboard

Adding functionality

Open dsbw opened this issue 3 years ago • 1 comments

I wanted to add some features not built-in to infix, so I did the following:

  1. Defined the routines I wanted to use:
(defn max [a, b] (Math/max a, b))
(defn min [a, b] (Math/min a, b))
  1. Created a map with those routines:
(def obz-fns {:max max
              :min min})
  1. Merged them into the existing routines:
(def all-fns (merge base-env obz-fns))
  1. I then use my all-fns when calling from-string:
((from-string [] (merge all-fns local-vars)  "min(a,b)")))

This seems to be pretty trauma free. Just wondering if I should beware of any particular dangers.

dsbw avatar Feb 07 '22 05:02 dsbw

That is usage exactly as intended

rm-hull avatar Feb 07 '22 08:02 rm-hull