Created
August 2, 2019 09:07
-
-
Save eltray/18fcd1ec25832124a56b00f53bbe00ab to your computer and use it in GitHub Desktop.
Learning Dart - 6. Use Dart for functional programming
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
String scream(int length) => "A${"a" * length}h!"; | |
main() { | |
var values = [1, 2, 3, 4, 10]; | |
// Imperative way | |
// for (int length in values){ | |
// print(scream(length)); | |
// } | |
// Functional way | |
// values.map(scream).forEach(print); | |
values.skip(1).take(3).map(scream).forEach(print); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment