Giter Site home page Giter Site logo

frins's Introduction

Frins

Frins is a practical unit-of-measure calculator DSL for Scala.

Key features;

  • Tracks units of measure through all calculations allowing you to mix units of measure transparently
  • Comes with a huge database of units and conversion factors
  • Inspired by the Frink project and Frinj
  • Tries to combine Frink's fluent calculation style with idiomatic Scala

Artifacts

Add the following lines to your build.sbt

resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"

libraryDependencies += "io.github.martintrojer" % "frins_2.10" % "0.1-SNAPSHOT"

Usage

Turn your sbt console into an (even more) powerful calculator;

$ sbt console
scala> import frins._
scala> initDatabases

You are now ready to go! Frins keeps it's values in instances of the Number class, which contains a Double value and a Map of Units. Once you have a Number object you can use it in calculations as you would normally use Doubles.

There are convenience Frins Number builders using the form N(value, 'unit, 'unit, ...) (value can be omitted) and implicits conversions from other number types and scala symbols (denoting the unit) to Frins Numbers.

scala> 'teaspoon * 'water * ('c ** 2)
res0: frins.Number[Double] = 4.429893807970541E14 m^2 kg s^-2 [energy]

That's the energy contained in one teaspoon of water (using E=mc^2). Wow, big number, how much is that "in real money"?

scala> res0 to 'gallons * 'gasoline
res1: frins.NumberT = 3164209.8628361006  [dimensionless]

There you have it, the energy in one teaspoon of water (according to Einstein) is equivalent to burning 3 million (!) gallons of gasoline.

For more examples and explanations of the Number builders (and more!) see the example calculations below.

Examples

Finally, check the wiki for more information.

License

Copyright (C) 2013 Martin Trojer

Distributed under the Eclipse Public License.

frins's People

Contributors

martintrojer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.