|
|
|
|
|
by taliesinb
4329 days ago
|
|
Yeah, it's pretty easy to turn Map[#^2&] /* Select[PrimeQ] /* Select[OddQ]
into Select[OddQ[#] && PrimeQ[#]&] /* Map[#^2&]
and so on via rules that look like: Select[s1_] /* Select[s2_] :> Select[s1[#] && s2[#]&]
Map[f_ ? SideEffectFreeQ] /* s_Select :> s /* Map[f]
Map[Extract[p_Integer | p_Key]] :> Extract[{All, p}]
I'm already doing a bunch of that for Dataset.But in reality you need to move to a DSL for complex enough rules, and then Clojure and WL will be on the same footing (Clojure even a bit stronger, maybe, WL doesn't really have a proper macro system). Does Clojure core do or allow for any of that kind of optimization already? |
|
[0] http://clhs.lisp.se/Body/m_define.htm