[racket] Numbers with dimensions

From: Laurent (laurent.orseau at gmail.com)
Date: Tue Oct 29 09:24:32 EDT 2013

Pushed: https://github.com/Metaxal/measures#4-dimensions-and-contracts

Laurent


On Tue, Oct 29, 2013 at 12:14 PM, Laurent <laurent.orseau at gmail.com> wrote:

> That's a good idea, and it's quite easy to implement using contracts!
> Would something like this suit you? (this is currently working as is)
> https://gist.github.com/Metaxal/7212740
>
>
> Laurent
>
>
>
> On Tue, Oct 29, 2013 at 11:40 AM, Konrad Hinsen <
> konrad.hinsen at fastmail.net> wrote:
>
>> Laurent writes:
>>
>>  > So I've redesigned it somewhat, and now there are 2 calculation
>> "modes":
>>  > - The normal mode is pretty much like Frink (probably the one you
>> want), which converts
>>  > everything to base SI units. Conversion back to non base units can be
>> done afterwards.
>>
>> Well, what I really want is something else, but this is a useful
>> feature nevertheless for a unit calculator. It would be nice though if
>> the default units to which everything is converted were modifiable. SI
>> units are fine for engineering and daily life, but neither for
>> astrophysics nor for atomic-scale measurements.
>>
>> What I personally care about most is dimensional analysis as a means
>> of ensuring program correctness. I want to be able to write
>>
>>   (define: (kinetic-energy (m : Mass) (v : Velocity) : Energy
>>     (m* 1/2 m v v))
>>
>> and then compute the kinetic energy of a car as
>>
>>   (kinetic-energy (m 1000 kg) (m 90 km (h -1)))
>>
>> whereas a typical mistake such as
>>
>>   (kinetic-energy (m 1000 kg) (m 90 km h))
>>
>> would get caught by the type checker (ideally) or at run time. With a
>> unit-converter approach such as the one you implemented, the erroneous
>> call would be accepted and an error would be detected only if the
>> result is later converted to an explicitly named energy unit.
>>
>> Konrad.
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131029/81f33a1a/attachment.html>

Posted on the users mailing list.