Giter VIP home page Giter VIP logo

functional-programming's Introduction

Functional Programming

Typeclasses

Monoids

Things Operation Closed? Associative? Identity? Classification
Int32 Addition Yes Yes 0 Monoid
Int32 Multiplication Yes Yes 1 Monoid
Int32 Subtraction Yes No 0 Other
Int32 Max Yes Yes Int32.MinValue Monoid
Int32 Equality No Other
Int32 Less than No Other
Float Multiplication Yes No (See note 1) 1 Other
Float Division Yes (See note 2) No 1 Other
Positive Numbers Addition Yes Yes No identity Semigroup
Positive Numbers Multiplication Yes Yes 1 Monoid
Boolean AND Yes Yes true Monoid
Boolean OR Yes Yes false Monoid
String Concatenation Yes Yes Empty string "" Monoid
String Equality No Other
String "subtractChars" Yes No Empty string "" Other
List Concatenation Yes Yes Empty list [] Monoid
List Intersection Yes Yes No identity Semigroup

[Note 1] Floats are not associative. Replace ‘float’ with ‘real number’ to get associativity.

[Note 2] Mathematical real numbers are not closed under division, because you cannot divide by zero and get another real number. However, with IEEE floating point numbers you can divide by zero and get a valid value. So floats are indeed closed under division! Here’s a demonstration:

let x = 1.0/0.0 // infinity
let y = x * 2.0 // two times infinity
let z = 2.0 / x // two divided by infinity

functional-programming's People

Contributors

lukepatterson31 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.