Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save evaporei/10317ddd1d63f3ef420309b4ff1cd682 to your computer and use it in GitHub Desktop.

Select an option

Save evaporei/10317ddd1d63f3ef420309b4ff1cd682 to your computer and use it in GitHub Desktop.
Category Theory - Monoid Integer Multiplication
Number.prototype.mappend = function (x: Number): Number {
return this * x
}
Number.prototype.mempty = function (): Number {
return 1
}
console.log('mappend:', Number(5).mappend(4)) // 20
console.log('mempty:', Number().mempty()) // 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment