- Wrapper of
List<List<T>>
asList2D<T>
- List shaped tree processing utilities
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
/// Buffered stream sink that uses a string buffer. | |
class BufferedStringSink implements StringSink { | |
final buffer = new StringBuffer(); | |
final int bufferThreshold; | |
final StringSink target; | |
BufferedStringSink(this.target, {this.bufferThreshold: 10000}); | |
void flush() { | |
target.write(buffer); |
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
void main() { | |
final mappedIterable = ['a', 'b', 'c', 'd'].map((ch) { | |
print('mapped $ch'); | |
return ch; | |
}).where((ch) { | |
return ch != 'a'; | |
}); | |
if (mappedIterable.isNotEmpty) { | |
print('iterable is non-empty'); | |
print(mappedIterable.first); |
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
void main() { | |
final data = new List.generate(100, (i) => i); | |
final result = data.where((i) { | |
print('where $i'); | |
return i > 0 && i % 10 == 0; | |
}).map((i) { | |
print('map $i'); | |
return i / 10; | |
}); | |
print('=========='); |
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
body { | |
font-family: monospace; | |
} | |
.title { | |
font-size: 1em; | |
font-weight: bold; | |
text-decoration: underline; | |
padding: 1em; | |
} |
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
typedef R Fn1<R, T1>(T1 arg1); | |
typedef R Fn2<R, T1, T2>(T1 arg1, T2 arg2); | |
Fn1<Fn1<R, T2>, T1> curry12<R, T1, T2>(Fn2<R, T1, T2> fn) { | |
return (T1 arg1) => (T2 arg2) => fn(arg1, arg2); | |
} | |
Fn1<Fn1<R, T1>, T2> curry21<R, T1, T2>(Fn2<R, T1, T2> fn) { | |
return (T2 arg2) => (T1 arg1) => fn(arg1, arg2); | |
} |
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
typedef bool Case<T>(T input); | |
Case<num> gt(num than) => (num x) => x != null && x > than; | |
Case nil = (instance) => instance == null; | |
O match<T, O>(T input, Map<dynamic, Function> cases) { | |
for (final _case in cases.keys) { | |
if (_case == input || (_case is Function && _case(input) == true)) { | |
return cases[_case](); | |
} | |
} |
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
/// Unpack an integer list into a list of integer lists. | |
List<List<int>> _unpackIntLists(List<int> input) { | |
final output = new List<List<int>>(); | |
for (var i = 0; i < input.length;) { | |
final length = input[i++]; | |
output.add(input.sublist(i, i + length)); | |
i += length; | |
} | |
return output; | |
} |
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
/// A hack to copy a string to the clipboard. | |
bool _copyToClipboardHack(String text) { | |
final textarea = new TextAreaElement(); | |
document.body.append(textarea); | |
textarea.style.border = '0'; | |
textarea.style.margin = '0'; | |
textarea.style.padding = '0'; | |
textarea.style.opacity = '0'; | |
textarea.style.position = 'absolute'; | |
textarea.readOnly = true; |
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
// Copyright (c) 2017, Herman Bergwerf. All rights reserved. | |
// Use of this source code is governed by a MIT-style license | |
// that can be found in the LICENSE file. | |
.checkbox { | |
font-family: KaTeX_Main; | |
user-select: none; | |
padding: .3em; | |
&:before { |