<div dir="ltr">So does this mean you think the representation I took is bad for some reason? If so why?<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Oct 26, 2013 at 5:36 PM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>1. I would hope that some generics might help here. </div><div>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. </div>
<div><br></div><div>Data representation not fully thought thru. -- Matthias</div><div><div class="h5"><div><br></div><div><br></div><div><br></div><div><br></div><br><div><div>On Oct 26, 2013, at 11:26 AM, Laurent wrote:</div>
<br><blockquote type="cite"><div dir="ltr"><div><div>How would you represents quantities like 2 kg.m^2/s^-2 with that?<br></div><div>And how would you convert from mi/h to m/s?<br></div><div><br></div>Anyway, I've started adding in some converters:<br>
<a href="https://github.com/Metaxal/measures/blob/master/converters.rkt" target="_blank">https://github.com/Metaxal/measures/blob/master/converters.rkt</a><br><br></div>Some more to come, but I may not be able to work on it for very long for now.<br>
<br>Laurent<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Oct 26, 2013 at 5:05 PM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div><br></div><div>Wouldn't we want something like this: </div><div>
<br></div><div><div>#lang racket</div><div><br></div><div>(module+ test (require rackunit))</div><div><br></div><div>(struct distance (value) #:transparent) ;; this should be abstract </div><div>(struct yard distance () #:transparent)</div>
<div>(struct meter distance () #:transparent)</div><div><br></div><div>;; distance distance -> distance </div><div><br></div><div>(module+ test</div><div> (check-equal? (d+ (yard 1) (yard 2)) (yard 3))</div><div> (check-equal? (d+ (yard 1) (meter 2)) (meter (+ .9 2)))</div>
<div> (check-equal? (d+ (meter 1.8) (yard 1)) (yard (+ 2.0 1)))</div><div> (check-equal? (d+ (meter 2) (meter 1)) (meter 3)))</div><div><br></div><div>(define (d+ d1 d2) </div><div> (match (list d1 d2)</div><div> [(list (struct yard (value)) (struct yard (value2))) (yard (+ value value2))]</div>
<div> [(list (struct yard (value)) (struct meter (value2))) (meter (+ (yard->meter value) value2))]</div><div> [(list (struct meter (value2)) (struct yard (value))) (yard (+ (meter->yard value2) value))]</div>
<div> [(list (struct meter (value)) (struct meter (value2))) (meter (+ value value2))]))</div><div><br></div><div>;; distance distance-constructor -> distance </div><div><br></div><div>(module+ test </div><div> (check-equal? (conversion (yard 3) meter) (meter (* 3 .9))))</div>
<div><br></div><div>(define (conversion x d)</div><div> (match x </div><div> [(struct yard (y)) (if (eq? yard d) x (meter (yard->meter y)))]</div><div> [(struct meter (y)) (if (eq? yard d) (yard (meter->yard y)) x)]))</div>
<div><br></div><div><br></div><div>;; auxiliaries </div><div>(define (yard->meter v) (* .9 v))</div><div>(define (meter->yard v) (/ v .9))</div></div><span><font color="#888888"><div><br></div><div>-- Matthias</div>
</font></span><div><div><div><br></div><div><br></div><br><div><div>On Oct 26, 2013, at 7:20 AM, Laurent wrote:</div><br><blockquote type="cite"><div dir="ltr"><div><div><div>Ok, so I just hacked together a small lib for handling numbers with unit symbols and exponents:<br>
<br></div><div>Quick example:<br>> (measure->value<br> (m* '(18 s) <br> '(1600 km (h -1))<br>
'(1000 m (km -1))<br> '(1/3600 h (s -1))))<br>'(8000 m)<br><br></div>You can get it with:<br></div>$ raco pkg install measures<br></div><div>or from the File menu in DrRacket, if you have a recent version of Racket (strictly > 5.3.6).<br>
<br></div><div>Examples and details here:<br><a href="https://github.com/Metaxal/measures" target="_blank">https://github.com/Metaxal/measures</a><br><br></div><div>HTH,<br></div><div>Laurent<br></div></div><div class="gmail_extra">
<br>
<br>
<div class="gmail_quote">On Fri, Oct 25, 2013 at 12:51 AM, Alvin Schatte <span dir="ltr"><<a href="mailto:AlvinSchatte@skytex.net" target="_blank">AlvinSchatte@skytex.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div dir="ltr">
<div style="font-size:12pt;font-family:'Calibri'">
<div>Is there a library or package that combines numbers and their operations
with dimensions that may be associated with them?</div><span><font color="#888888">
<div style="font-size:12pt;font-family:'Calibri'">Alvin
Schatte<br></div></font></span></div></div></div>
<br>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br></blockquote></div><br></div>
____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br></blockquote></div><br></div></div></div></blockquote></div><br></div>
</blockquote></div><br></div></div></div></blockquote></div><br></div>