by sterlind · 4y ago · 0 comments
It's a neat design pattern. I bet it'd work in Julia too.
I'm only a beginner in Julia and not and AD expert, but I went through the exercise of porting this to python and found it very enlightening
I'm not sure I understand what this means. What is a symbolic language that excludes languages like Haskell, F#, OCaml, etc.?
It's like Lisp, if everything in Lisp were quoted, and eval consisted of pattern matching and applying substitution rules.
As an example, say in Haskell I have foo x y = x + 2/y. Can you write a function that takes any function in, and replaces all + with *? in Mathematica you can: foo[x_,y_] := x + 2/y; foo[x,y] /. l_ + r_ -> l*r.
I'm sure you can do this stuff in other languages if you try hard enough. Some kind of reflection in Haskell or F#. In Lisp, grab and quote the definition of foo and apply macro machinery to it. But that's not the tao of those languages, while it is the essence of Mathematica.