mikera / core.matrix

core.matrix : Multi-dimensional array programming API for Clojure
Other
700 stars 113 forks source link

Feature request: reverse and rotate functions #364

Open maxrothman opened 6 months ago

maxrothman commented 6 months ago

core.matrix has pretty good coverage of the APL primitives, but one notable exception is the reverse function (monadic ⌽ and ⊖). For 2d matrices with native Clojure sequences, one can work around the problem with (map reverse m), but it’d be nice to have non-abstraction-breaking core.matrix versions of these.

In a similar vein, there’s also no rotate functions. While you can work around this with (transpose (reflect m)), I suspect that a library implementation could achieve better performance.

mikera commented 6 months ago

Makes sense. Any preference for API? Remembering of course that arbitrary subsets of dimensions might get reversed or rotated.....

maxrothman commented 6 months ago

No particular preference! The multiple dimensions part definitely needs to be taken into account. I'd assume you don't want to make APL's mistake by splitting ⌽ and ⊖ as well.