Giter Club home page Giter Club logo

purescript-quantities's Introduction

purescript-quantities

A PureScript library to represent and work with physical quantities and units. Note that this library focuses on a representation at run time as opposed to other projects which use the type system to encode physical units at compile time.

Examples

> showResult $ 2.0 .* minute ⊕ 30.0 .* second
"2.5 min"

> showResult $ (85.0 .* mile ./ hour) `convertTo` (meter ./ second)
"37.9984 m/s"

> showResult $ (10.0 .* meter ./ second) `convertTo` (kilo meter ./ hour)
"36 km/h"

> log $ showResult $ (10.0 .* joule) `convertTo` watt
Cannot convert unit 'J' (SI: 'm²·g/s²')
            to unit 'W' (SI: 'm²·g/s³')

> showResult $ sin (90.0 .* degree)
"1"

Calculate the time it takes to download a 2.7GB file on a 6Mbit/s connection:

> let filesize = 2.7 .* giga byte
> let speed = 6.0 .* mega bit ./ second
> showResult $ (filesize ⊘ speed) `convertTo` minute
"60 min"

Calculate the oscillation period T = 2π sqrt(L/g) of a pendulum with length L = 20cm:

> let g = 9.81 .* meter ./ second .^ 2.0
> let length = 20.0 .* centi meter
> let period = scalar 2.0 ⊗ pi ⊗ sqrt (length ⊘ g)

> prettyPrint (fullSimplify period)
"0.89714 s"

Installation

bower install purescript-quantities
npm install decimal.js

Documentation

purescript-quantities's People

Contributors

abaco avatar anilanar avatar imacg avatar nunomarks avatar sharkdp 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.