Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace symbols with their aliases in ->clj also for - #89

Closed
light-matters opened this issue Jul 25, 2024 · 1 comment
Closed

Replace symbols with their aliases in ->clj also for - #89

light-matters opened this issue Jul 25, 2024 · 1 comment
Labels
enhancement New feature or request UX User/developer eXperience

Comments

@light-matters
Copy link
Contributor

light-matters commented Jul 25, 2024

I was adding tests to the custom-aliases branch when I noticed:

(is (= '(- 5 4)
         (wl/->clj "Subtract[5, 4]")))
(is (= '(- 5)
         (wl/->clj "Minus[5]")))

both fail. They return (Subtract 5 4) and (Minus 5), respectively, instead of (- 5 4) and (- 5). This is something due to the experimental-fn implementation.

Example where this works as expected:

(wl/->clj "Power[2,Rational[-1,2]]")
=> (** 2 -1/2)

This is, as suggested, most likely due to the fact that - has as alias a fn that maps either to Minus or Subtract and the code does not handle the reverse transformation.

@light-matters light-matters added the bug Something isn't working label Jul 25, 2024
@holyjak
Copy link
Member

holyjak commented Sep 13, 2024

They happens is that

(wl/->clj "Subtract[5, 4]") ; => (Subtract 5 4)
(wl/->clj "Minus[5]").        ; => (Minus 5)

while you expected to get '(- 5 4) and (- 5) - but we currently do not support reverse alias application and I see no need for it. We could do it (walk the transformed clj data, replace anything that has an alias with the alias)...

@holyjak holyjak added enhancement New feature or request UX User/developer eXperience and removed bug Something isn't working labels Sep 13, 2024
@holyjak holyjak changed the title Subtract and Minus are not converted to Clojure properly Replace symbols with their aliases in ->clj, where available Sep 13, 2024
@holyjak holyjak changed the title Replace symbols with their aliases in ->clj, where available Replace symbols with their aliases in ->clj also for - Sep 14, 2024
light-matters added a commit that referenced this issue Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request UX User/developer eXperience
Projects
None yet
Development

No branches or pull requests

2 participants