Created
May 18, 2018 12:21
-
-
Save agilob/4b5d6b12d51fb194f2d25540bb4a12ed to your computer and use it in GitHub Desktop.
Sleep sort implementation in Dart
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
import 'dart:async'; | |
class Input { | |
var sleepTimes = new List(); | |
} | |
main(List<String> arguments) async { | |
var input = new Input(); | |
arguments.forEach((val) { input.sleepTimes.add(num.parse(val)); } ); | |
input.sleepTimes.forEach((time) { | |
mSleep(time); | |
}); | |
} | |
mSleep(int value) async { | |
runFutures(value); | |
} | |
Future runFutures(int value) { | |
return runLater(value).then((result) { | |
print(value); | |
}); | |
} | |
Future runLater(int value) { | |
return new Future.delayed(new Duration(seconds: value)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment