hakaru icon indicating copy to clipboard operation
hakaru copied to clipboard

real2int function?

Open mkhattab940 opened this issue 7 years ago • 3 comments

The real2int function (which is specified here: http://hakaru-dev.github.io/lang/coercions/) does not seem to be implemented

Name not in scope: real2int

30| 	return real2int(num/(den1*den2))
                   ^^^^^^^^
Perhaps it is a typo?

mkhattab940 avatar Nov 21 '17 23:11 mkhattab940

I don't think it's implemented. It shouldn't be too tricky to do so. The main thing is to update primTable in https://github.com/hakaru-dev/hakaru/blob/master/haskell/Language/Hakaru/Parser/SymbolResolve.hs

Thank you for taking the time to make these issues. We really appreciate it :)

On Nov 21, 2017 23:46, "maymoo99" [email protected] wrote:

The real2int function (which is specified here: http://hakaru-dev.github.io/lang/coercions/) does not seem to be implemented

Name not in scope: real2int

30| return real2int(num/(den1*den2)) ^^^^^^^^ Perhaps it is a typo?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hakaru-dev/hakaru/issues/116, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAhUQ4XHbmaMKDCVDcYBlGmYk8GXNojks5s42C7gaJpZM4QmqAo .

zaxtax avatar Nov 21 '17 23:11 zaxtax

Thanks zaxtax. I was able to get it working. However, there seems to be rounding errors. How can I ensure I round to nearest integer?

mkhattab940 avatar Nov 22 '17 02:11 mkhattab940

So if you are using the hakaru command, the coercion logic you are hitting is https://github.com/hakaru-dev/hakaru/blob/master/haskell/Language/Hakaru/Syntax/Value.hs#L95

We chose to go with floor but if you think round is more sensible, it's easy enough to change.

On Nov 22, 2017 02:36, "maymoo99" [email protected] wrote:

Thanks zaxtax. I was able to get it working. However, there seems to be rounding errors. How can I ensure I round to nearest integer?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hakaru-dev/hakaru/issues/116#issuecomment-346225587, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAhUS8uLHZzNEsKxMbsi71XPn7M3m8xks5s44iLgaJpZM4QmqAo .

zaxtax avatar Nov 22 '17 02:11 zaxtax