https://github.com/modulovalue/abstract_dart
A collection of algebraic structures borrowed from abstract algebra. Semigroup, Monoid, Group & Field.
https://github.com/modulovalue/abstract_dart
abstractalgebra algebra dart dartlang field functional-programming group monoid pub semigroup vectorspace
Last synced: 7 months ago
JSON representation
A collection of algebraic structures borrowed from abstract algebra. Semigroup, Monoid, Group & Field.
- Host: GitHub
- URL: https://github.com/modulovalue/abstract_dart
- Owner: modulovalue
- License: bsd-2-clause
- Created: 2019-08-17T08:02:36.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-28T06:04:27.000Z (over 5 years ago)
- Last Synced: 2025-03-20T23:16:03.159Z (8 months ago)
- Topics: abstractalgebra, algebra, dart, dartlang, field, functional-programming, group, monoid, pub, semigroup, vectorspace
- Language: Dart
- Homepage: https://pub.dev/packages/abstract_dart
- Size: 109 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# abstract_dart
[](https://pub.dev/packages/extra_pedantic) [](https://travis-ci.com/modulovalue/abstract_dart) [](https://codecov.io/gh/modulovalue/abstract_dart) [](https://github.com/modulovalue/abstract_dart/blob/master/LICENSE) [](https://pub.dartlang.org/packages/abstract_dart) [](https://github.com/modulovalue/abstract_dart) [](https://twitter.com/modulovalue) [](https://github.com/modulovalue)
A collection of algebraic structures borrowed from abstract algebra. Semigroup, Monoid, Group, Field, and more.
Take a look at [abstract_flutter](https://github.com/modulovalue/abstract_flutter) for Flutter structures.
Example:
```dart
/// Create a semigroup
final semigroup = Semigroup_.create((a, b) => a + b);
/// Create a monoid
final monoid = Monoid_.create(() => 0.0, (a, b) => a + b);
/// Create a group
final group =
Group_.create(() => 0.0, (a, b) => a + b, (a, b) => a - b);
/// Create a field
final field = Field_.create(
Group_.create(() => 0.0, (a, b) => a + b, (a, b) => a - b),
Group_.create(() => 1.0, (a, b) => a * b, (a, b) => a / b),
);
/// Monoids
const bigIntSumMonoid = BigIntSumMonoid();
const bigIntProductMonoid = BigIntProductMonoid();
const decimalSumMonoid = DecimalSumMonoid();
const decimalProductMonoid = DecimalProductMonoid();
const stringConcatMonoid = StringConcatMonoid();
const numSumMonoid = NumSumMonoid();
const numProductMonoid = NumProductMonoid();
const intSumMonoid = IntSumMonoid();
const intProductMonoid = IntProductMonoid();
const doubleSumMonoid = DoubleSumMonoid();
const doubleProductMonoid = DoubleProductMonoid();
/// Groups
const bigIntSumGroup = BigIntSumGroup();
const decimalSumGroup = DecimalSumGroup();
const decimalProductGroup = DecimalProductGroup();
const doubleProductGroup = DoubleProductGroup();
const doubleSumGroup = DoubleSumGroup();
const numProductGroup = NumProductGroup();
const numSumGroup = NumSumGroup();
/// Fields
const decimalField = DecimalField();
const doubleField = DoubleField();
const numField = NumField();
```
#### `Semigroup_`
- An operation of type A+A => A
#### `Monoid_` (a `Semigroup_`)
- An operation of type A+A => A
- An identity element so that a+e = a
#### `Group_` (a `Monoid_`, a `Semigroup_`)
- An operation of type A+A => A
- An inverse operation of type A-A => A
- An identity element so that a+e = a
#### `Field_`
- A Group (addition)
- A Group (multiplication)
#### `ScalarMonoid_`
- An operation of type K•F => K
- An identity element so that K•e = K
#### `VectorSpace_`
- A Group (addition)
- A ScalarMonoid (scalar multiplication)
#### `Algebra_` (a `VectorSpace_`, a `Field_`)
- A Group (addition)
- A Group (multiplication)
- A ScalarMonoid (scalar multiplication)
abstract_dart does not enforce any of the properties that these structures require in a mathematical setting.