GithubHelp home page GithubHelp logo

unit-formula's People

Contributors

cddr avatar elliottjohnson avatar ramarren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

unit-formula's Issues

Using unit-formula

Hello,
I would be interested how I could use unit-formula in the following situation:
I have a set of physical parameters with units and would like to calculate from those dimensionless parameters for inserting them in a numerical calculation.
Should I declare those parameters all with define-units and then define formulae involving those parameters?
Thanks, Nicolas

Precision of conversions

Hi,

I believe that many of the length conversions can be more accurately expressed as ratios rather than floats. For example, centimeters is expressed as 0.01. This results in the following...

(convert-unit '(100.00 cm) 'm) => 0.9999999776482582d0

It looks like it was done this way in the original novak library. Do you think this is for efficiency's sake?

Regards,
Andy

Adding units?

Hello,
I (or, more precisely, a student of mine) wanted to add units as follows:
(define-units volume-a (1 ml))
(define-units volume-b (2 ml))
(define-units total-volume (+ volume-a volume-b))
... which does not work ("cannot add units of different dimensions"). However, as much as I see, the dimensions should fit?
Thank you,
Nicolas

Formulas within formulas

Thanks for this library, it's been amazing to work with. I was wondering if you have given thought to allowing formulas as operators within a formula?

A trival example would be:

(defformula* area ((length meters) (width meters))
  (* length width))

(defformula* volume ((length meters) (width meters) (height meters))
  (* (area length width) height))

;;; a trival and inaccurate version of the 4th dimension 
(defformula* space-time ((length meters) (width meters) (height meters) (time seconds))
  (* (volume length width height) time))

In writing some code I came to the point of trying to build formulas based upon other formulas. To do so I was rewriting a lot of code for each higher level formula like this:

(defformula* area ((length meters) (width meters))
  (* length width))

(defformula* volume ((length meters) (width meters) (height meters))
  (* length width height))

(defformula* space-time ((length meters)(width meters)(height meters)(time seconds))
  (* length width height time))

Not so bad, but increasing complexity begs for code reuse. Another option seems to be writing a lot of small formulas called by a parent function like this:

(defformula* area ((length meters) (width meters))
  (* length width))

(defformula* %volume% ((area m^2)(height meters))
  (* area height))

(defun volume (length width height)
  (%volume% (area length width) height))

(defformula* %space-time% ((volume m^3) (time seconds))
  (* volume time))

(defun space-time (length width height time)
  (%space-time% (volume length width height) time))

This allows for code reuse, which is great, but enlarges the amount of "boilerplate". By allowing for formulas to call other formulas I think it would give the most code reuse as well as remove the need for extra code. How have you dealt with the subject of complex formulas that build upon each other in your practical coding?

Thanks again for reviving this library, modernizing it, and sharing.

Cheers,
-Elliott

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.