Skip to content

Instantly share code, notes, and snippets.

View MelvIsntNormal's full-sized avatar

Melvin Sowah MelvIsntNormal

  • Manchester, UK
View GitHub Profile
var async = (function () {
/*
This is my attempt at implementing a C#/Dart style async/await feature.
This is just a learning exercise, and I probably wouldn't use it in
production sites.
This code is broken: when await is called, not only is the program blocked
("called expensice function" is never written to the console), the Promise
doesn't actually execute its 'then' callback.
import "dart:io";
import "dart:convert";
int main() async {
Map<int, List<int>> nodes = {};
int maxNodes = null;
List<int> emptyNode() => new List<int>.filled(maxNodes, 0);
// initialises node if it doesn't yet exist
List<int> node(int i) {