Hej Tomi, I have attached an example, in which 30s evaluates to (sec 30).
The idea is a follows: 30s is an identifier, therefore if 30s is unbound, then 30s is a reference to a top-level variable. References top top-level variables expand to (#%top . 30s). The standard #%top will raise an error (identifier unbound). The trick is now to redefined #%top to treat identifiers that end with s in a special way. See attached for details. /Jens Axel 2014-09-30 17:11 GMT+02:00 Tomi Pieviläinen <[email protected]>: > First apologies to Alexsandro Soares, if I'm intruding, but I wasn't > sure if you were on the mailing list and you were asking about this in > June. > > I tested how well Racket runs on the Lego Mindstorms EV3 (with > ev3dev), and found out that there is enough memory on the device to > get a REPL running. The loading time is somewhat annoying, but not > prohibitive. I also started creating a library for using the ev3dev > kernel exposed file based API. I tested that I can use the color and > ultrasonic sensors, and motors. The rest is simple from those. > > I'm a bit stuck by trying to grok Racket better. I'm thinking about > possibility to have some kind of "typed literals" for distance, time > and angle, so that I could use (move-robot 11cm) or (move-robot 11s) > like calls, instead of having separate functions for time and distance > variables, or having to create the values with (cm 11) or such. > > Not sure if that makes any sense, but I was thinking that it might > feel more natural and also I'm interested in seeing how easily it > could be done. > > -- > Tomi Pieviläinen, +358 400 487 504 > A: Because it disrupts the natural way of thinking. > Q: Why is top posting frowned upon? > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -- -- Jens Axel Søgaard
units-for-lego.rkt
Description: Binary data
use-units-for-lego.rkt
Description: Binary data
____________________ Racket Users list: http://lists.racket-lang.org/users

