I thought of something. The first step is to perform all arithmetic functions given units, the second is to convert from one unit to another.
So first, take 24 gm results from 4 m3 times 6 gm/m3 24 1 0 0 =4 0 3 0 * u 6 1 _3 0 The first number (24 4 6) in each list is a dimensionless multiplier, the next 3 are the exponent of 'gm m s' (grams, meters, seconds). So the exponents function * &.^ and the multipler just *. Would work for divide. Probably a simple adverb could do this. Then somehow you have to have definitions like Pa (pascals) = 1 1 _1 _2, and also lb=0.4535962 1 0 0 . I'm not sure this would work in enough situations, but seems like it, after all, handling units is dead simple, but this may be clean enough, and simpler than doing it by hand, or what I do, going bakc and forth between Mathcad and J. Maybe someone could pick holes at this. There might be a better way. Might not work at all. But it would be best if this is sensible in an array sense rather than a parsing sense, that is, hold the info in a vector rather than in text. MatchCad seems to have solved the problem, it's just that MatchCad can't do what J does, and handles matrices sort of funky. It doesn't have nearly the efficiency or flexibility of J, and can't be easily programmed. If you can see the attached gif file, Pa has a black square next to it. If I click on it, I can enter what you see to the right: the gm/ms2, and it calculates that appropriately. On 10/24/07, Devon McCormick <[EMAIL PROTECTED]> wrote: > At APL2007, from which I just returned, Guy Steele spoke about a language > called "Fortress", > on which they're working at Sun, that allows numbers to be specified with > units attached to them. > Of course this doesn't help you in J - and probably not for some time even > in that language as it's > still under development with a long time horizon. > > I once toyed with the notion of implementing dimensioned numbers by working > with each number as > a pair where the second number would be a prime arbitrarily associated with > a unit of measure. > > This would allow you to factor the second number - possibly as a rational - > to figure out the base units > in a calculation resulting in some compound unit such as kg-m/(seconds^2). > However, addition would > become more complicated as you would have to dis-allow adding numbers with > mismatched units and > it's not clear how you could simply do this in J. > > Please keep us informed if you come up with a way to do this for your > purposes. > > >Frank Hamilton <[EMAIL PROTECTED]> to programming > > >Has anyone considered an application to calculate with systems of > >units, such as SI? I understand that it would be difficult to include > >in the primitives, but as an application it would be extremely useful > >a lot of the time. It would attract a lot of users. MathCad is a good... > > -- > Devon McCormick, CFA > ^me^ at acm. > org is my > preferred e-mail > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm >
---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
