Re: [racket] Numbers with dimensions

2013-11-07 Thread Konrad Hinsen
Laurent writes: > so many useful ones anyway. Each client module would then require the > module with the unit system it needs, i.e. measures/si or > measures/atomic. > > The units are now in a separate file but I did not try to build another base. > But at least it's possible to r

Re: [racket] Numbers with dimensions

2013-10-31 Thread Laurent
On Wed, Oct 30, 2013 at 10:32 AM, Konrad Hinsen wrote: > Laurent writes: > > > Pushed: https://github.com/Metaxal/measures#4-dimensions-and-contracts > > This is getting better and better every day! The use of contracts looks > like the best way to do run-time dimensional analysis. > Thanks, tha

Re: [racket] Numbers with dimensions

2013-10-30 Thread Konrad Hinsen
Laurent writes: > Pushed: https://github.com/Metaxal/measures#4-dimensions-and-contracts This is getting better and better every day! The use of contracts looks like the best way to do run-time dimensional analysis. My only remaining wish is to be able to define my own set of units and prefixes

Re: [racket] Numbers with dimensions

2013-10-29 Thread Laurent
Pushed: https://github.com/Metaxal/measures#4-dimensions-and-contracts Laurent On Tue, Oct 29, 2013 at 12:14 PM, Laurent 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.

Re: [racket] Numbers with dimensions

2013-10-29 Thread Laurent
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 wrote: > Laurent writes: > > > So I've redesigned it som

Re: [racket] Numbers with dimensions

2013-10-29 Thread Konrad Hinsen
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 rea

Re: [racket] Numbers with dimensions

2013-10-28 Thread Norman Gray
Greetings. On 2013 Oct 28, at 11:05, Laurent wrote: > 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

Re: [racket] Numbers with dimensions

2013-10-28 Thread Hendrik Boom
On Mon, Oct 28, 2013 at 07:54:22AM +0100, Konrad Hinsen wrote: > Laurent writes: > > > Indeed, the notion of dimension is not really what I was after. My > intention was rather > > to provide a useful unit converter. > > Fair enough. > > > If my current units are in N, and I multiply by squa

Re: [racket] Numbers with dimensions

2013-10-28 Thread Laurent
Point taken. 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. - The "quoted" mode prevents a unit fr

Re: [racket] Numbers with dimensions

2013-10-27 Thread Konrad Hinsen
Laurent writes: > Indeed, the notion of dimension is not really what I was after. My intention > was rather > to provide a useful unit converter. Fair enough. > If my current units are in N, and I multiply by square seconds, I > think it's not always desirable for the measure to be automat

Re: [racket] Numbers with dimensions

2013-10-27 Thread Laurent
That's a cool language! Unfortunately time is running short and I don't think I'll do something close to that (and there is actually little chance that I'll use this package myself, so I'm not really committed to it). But I think it's already quite usable. And anyone who wants to contribute or even

Re: [racket] Numbers with dimensions

2013-10-27 Thread Laurent
Indeed, the notion of dimension is not really what I was after. My intention was rather to provide a useful unit converter. If my current units are in N, and I multiply by square seconds, I think it's not always desirable for the measure to be automatically converted to m.kg. Currently it does not

Re: [racket] Numbers with dimensions

2013-10-27 Thread Jens Axel Søgaard
In case you need ideas for interesting examples: http://futureboy.us/frinkdocs/#SampleCalculations The Frink language is a DSL for calculating with units. http://futureboy.us/frinkdocs/ /Jens Axe 2013/10/26 Laurent : > Ok, so I just hacked together a small lib for handling numbers with u

Re: [racket] Numbers with dimensions

2013-10-26 Thread Konrad Hinsen
Laurent writes: > Examples and details here: > https://github.com/Metaxal/measures At first glance, I miss the notion of "dimension", which defines if two units are compatible, i.e. can be converted. If I understand your approach correctly (which I am not sure about), you consider each product

Re: [racket] Numbers with dimensions

2013-10-26 Thread Richard Cleis
A few years ago, my approach (which didn't get very far) was to internally maintain values in some chosen internal units; this input conversion occurred once, when variables were defined or otherwise introduced into the program. The conversion to the user-desired units then took place once via f

Re: [racket] Numbers with dimensions

2013-10-26 Thread Matthias Felleisen
The last line applies to my thoughts not yours. As someone else indicated, I think we should experiment with 'dimension' (distance, time) vs 'units' (meters vs yards, seconds vs hours). This separation injects a hierarchy that could be useful. I'd really like to see some experimentation here

Re: [racket] Numbers with dimensions

2013-10-26 Thread Laurent
So does this mean you think the representation I took is bad for some reason? If so why? On Sat, Oct 26, 2013 at 5:36 PM, Matthias Felleisen wrote: > > 1. I would hope that some generics might help here. > 2. I see a need for struct mixins here because meter isn't a refinement > per se but some

Re: [racket] Numbers with dimensions

2013-10-26 Thread Matthias Felleisen
1. I would hope that some generics might help here. 2. I see a need for struct mixins here because meter isn't a refinement per se but some 'attribute'. Then you could mixin several different units and I may have both m and m-1. Data representation not fully thought thru. -- Matthias On

Re: [racket] Numbers with dimensions

2013-10-26 Thread Laurent
How would you represents quantities like 2 kg.m^2/s^-2 with that? And how would you convert from mi/h to m/s? Anyway, I've started adding in some converters: https://github.com/Metaxal/measures/blob/master/converters.rkt Some more to come, but I may not be able to work on it for very long for now

Re: [racket] Numbers with dimensions

2013-10-26 Thread Matthias Felleisen
Wouldn't we want something like this: #lang racket (module+ test (require rackunit)) (struct distance (value) #:transparent) ;; this should be abstract (struct yard distance () #:transparent) (struct meter distance () #:transparent) ;; distance distance -> distance (module+ test (check-

Re: [racket] Numbers with dimensions

2013-10-26 Thread Laurent
Ok, so I just hacked together a small lib for handling numbers with unit symbols and exponents: Quick example: > (measure->value (m* '(18 s) '(1600 km (h -1)) '(1000 m (km -1)) '(1/3600 h (s -1 '(8000 m) You can get it with: $ raco pkg install measures or from the File

Re: [racket] Numbers with dimensions

2013-10-25 Thread Thomas Chust
On 2013-10-25 14:29, Konrad Hinsen wrote: > [...] > A quick Google search led me to > > http://en.wikibooks.org/wiki/F_Sharp_Programming/Units_of_Measure > > which says > >"Important: Units of measure look like a data type, but they > aren't. .NET's type system does not support the be

Re: [racket] Numbers with dimensions

2013-10-25 Thread Konrad Hinsen
Thomas Chust writes: > in that respect, the type system of F# may be noteworthy, too. The > support for dimensions is built into the language in that case. Interesting. A quick Google search led me to http://en.wikibooks.org/wiki/F_Sharp_Programming/Units_of_Measure which says "Importa

Re: [racket] Numbers with dimensions

2013-10-25 Thread Thomas Chust
On 2013-10-25 12:14, Konrad Hinsen wrote: > [...] > In fact, the only approaches > I know of that use static type checking are Boost.Units for C++ > (http://www.boost.org/doc/libs/1_54_0/doc/html/boost_units.html), > and the units package for Haskell (http://hackage.haskell.org/package/units). > [.

[racket] Numbers with dimensions

2013-10-25 Thread Konrad Hinsen
Alvin Schatte writes: > Is there a library or package that combines numbers and their > operations with dimensions that may be associated with them? Apparently not, from what I learn from previous discussions on this list. Doing this well is actually far from trivial, in any language, but it w

Re: [racket] Numbers with dimensions

2013-10-24 Thread Richard Cleis
This discussion reappears occasionally, and there are some accomplishments. You can start here to at least figure out how to search for more info: http://lists.racket-lang.org/users/archive/2011-November/049198.html rac On Oct 24, 2013, at 4:51 PM, Alvin Schatte wrote: > Is there a library or

[racket] Numbers with dimensions

2013-10-24 Thread Alvin Schatte
Is there a library or package that combines numbers and their operations with dimensions that may be associated with them? Alvin Schatte Racket Users list: http://lists.racket-lang.org/users