Is there a way to redefine the syntax in the top level of Racket to accept quaternions so it will evaluate it as a datum similar to complex numbers? I am trying to get 1+i+j+k to be accepted by the REPL. Any code examples or relevant documentation would be very helpful. -Edit I do having a working Quaternion module, and a parser that works but is a function call. I want to be able to type in 9+i-3j+k and it automatically be evaluated like other number types in racket.
Asked
Active
Viewed 90 times
-2
-
i'm not versed in the math there, but this seems too broad. you need to give it an earnest shot .. then come back w/ error messages/etc – Caffeinated Feb 24 '14 at 19:20
1 Answers
1
Yes, you can do this, though it may be a good deal of work. In particular, you're going to need to define your own "reader".
Before you do that, though: have you already implemented quaternions in the existing system? Adding the new reader should be the last step, after you have quaternions working without the syntax extension.

John Clements
- 16,895
- 3
- 37
- 52