-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: account for expand min/max bounds (#82)
* Add tests for min/max bounds on expand children * Implement distribution algorithm * Fix overflow in custom divider example * Fix bug in shrink example * Clean up logic * Remove indices after loop * Improve signature of constraint copy helper * Fix method name in tests * Add Decimal package to help with floating-point math * Fix layout bug with Decimals * Split "sum" into specific extensions on Int and Double * Add "indicesWhere" extension * Clean up * Fix ListIntExtension and use it in flex count * Fix Map construction * Fix "ListDoubleExtensions" name * Replace usages of "fold" * Remove remaining usages of "fold" * Remove unnecessary parens
- Loading branch information
Showing
12 changed files
with
363 additions
and
161 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
extension IterableNumExtensions on Iterable<num> { | ||
num sum() => fold(0, (sum, current) => sum + current); | ||
} | ||
|
||
extension IterableExtensions<T> on Iterable<T> { | ||
int nullCount() => where((item) => item == null).length; | ||
|
||
int count(bool Function(T) test) => where(test).length; | ||
|
||
num sum(num Function(T) extractor) => fold( | ||
0.0, | ||
(sum, current) => sum + extractor(current), | ||
); | ||
|
||
Iterable<T> evenIndices() => [ | ||
for (var i = 0; i < length; i++) ...[ | ||
if (i % 2 == 0) ...[ | ||
elementAt(i), | ||
], | ||
], | ||
]; | ||
|
||
Iterable<int> indicesWhere(bool Function(T) test) => [ | ||
for (var i = 0; i < length; i++) ...[ | ||
if (test(elementAt(i))) ...[ | ||
i, | ||
], | ||
], | ||
]; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:decimal/decimal.dart'; | ||
|
||
extension DoubleExtensions on double { | ||
Decimal toDecimal() => Decimal.parse(toString()); | ||
} | ||
|
||
extension ListDoubleExtensions on Iterable<double> { | ||
double sum() => fold(0.0, (sum, curr) => sum + curr); | ||
} | ||
|
||
extension ListIntExtensions on Iterable<int> { | ||
int sum() => fold(0, (sum, curr) => sum + curr); | ||
} |
Oops, something went wrong.