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

Add support for ratio #117

Closed
wants to merge 5 commits into from

Conversation

jianlingzhong
Copy link
Contributor

Add support for ratio

Currently, ratio (of two integers) will be converted to a real number during parsing.

Lexing and parsing should work:

❯ build/jank repl   
Bottom of clojure.core
> 4/5
0.8
> 4/5/6
Read error (0 - 3): invalid number
> 4//5
Read error (0 - 4): invalid number
> 4/5/6/7
Read error (0 - 3): invalid number
> 4.4/5
Read error (0 - 3): invalid number
> 5/5.5
Read error (0 - 5): invalid number
> 5/7
0.7142857142857143
> (+ 4 4/5)
4.8
> (+ 4 -4/5)
3.2
> (+ 4 4/-5)
3.2
> (+ 4 -4/-5)
4.8
> (+ -4/5 -4/-5)
0
> 1/0
Read error (0 - 0): Divide by zero

Currently, ratio (of two integers) will be converted to a real number during parsing.
@jianlingzhong jianlingzhong force-pushed the ratio branch 2 times, most recently from 616bb41 to 1d373d9 Compare October 22, 2024 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants