Last active
November 9, 2020 21:30
-
-
Save antklim/21e8171619c85ffb66c2cd9c3604b507 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef Operator = num Function(num) Function(num); | |
| typedef OperatorFmt = String Function(num) Function(num); | |
| class Operation { | |
| final String name; | |
| final Operator oper; | |
| final OperatorFmt format; | |
| Operation({this.name, this.oper, this.format}); | |
| @override | |
| String toString() => name; | |
| } | |
| final Add = Operation( | |
| name: 'Addition', | |
| oper: (num b) => (num a) => a + b, | |
| format: (num b) => (num a) => '$a + $b', | |
| ); | |
| final Sub = Operation(...); | |
| final Mul = Operation(...); | |
| final Div = Operation(...); | |
| final Sqrt = Operation( | |
| name: 'Square root', | |
| oper: (_) => (num a) => sqrt(a), | |
| format: (_) => (num a) => 'sqrt($a)', | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment