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
// Example borrowed from http://algs4.cs.princeton.edu/ | |
class cardShuffle { | |
String _cards; | |
cardShuffle() { | |
} | |
void run() { | |
_cards = "2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC AC " + |
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
class ListExtension { | |
/** | |
* Returns a [List] of indexes of the given [element], starting | |
* the search at index [startIndex] to [endIndex] (exclusive). | |
* Returns an empty [List] if [element] is not found. | |
*/ | |
static List<num> indexesOf(List list, Object element, int startIndex, int endIndex) { | |
List<num> n = new List<num>(); | |
if (startIndex >= list.length) { |
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
rm -rf dart snapshots && | |
mkdir snapshots && | |
cd snapshots && | |
wget http://gsdview.appspot.com/dart-editor-archive-continuous/latest/dart-editor-macosx.cocoa.x86_64.zip | |
cd ../ && | |
tar -zxvf snapshots/dart-editor-macosx.cocoa.x86_64.zip && | |
cd dart && | |
echo "./DartEditor.app/Contents/MacOS/DartEditor" > runDartEditor.sh && | |
chmod +x runDartEditor.sh && | |
cd dart-sdk && |
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:html'); | |
class A { | |
List _l; | |
} | |
class B extends A { | |
List _l; | |
} |
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:html'); | |
class DartiumBug { | |
DartiumBug() { | |
} | |
void run() { | |
num n = Math.pow(10, 4); | |
write("n = ${n}"); |
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:html'); | |
class dartEventsExample { | |
int counter = 0; | |
dartEventsExample() { | |
} | |
void run() { | |
document.query('#status').on.click.add((var event) { |
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:html'); | |
class SVGSamples { | |
void run() { | |
drawlines(); | |
} | |
void drawlines() { | |
final int maxY = 250; |
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
#!/usr/bin/env dart | |
#import('dart:isolate', prefix:'isolate'); | |
isolateCode() { | |
isolate.port.receive((msg, reply) => reply.send("re: $msg")); | |
} | |
void main() { | |
isolate.SendPort sendPort = isolate.spawnFunction(isolateCode); |
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:isolate', prefix:'isolate'); | |
costlyQuery() { | |
isolate.port.receive((msg, reply) => reply.send("costly")); | |
} | |
expensiveWork() { | |
isolate.port.receive((msg, reply) => reply.send("expensive")); | |
} |
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:isolate', prefix:'isolate'); | |
List split(List numbers) { | |
int size = numbers.length; | |
int middleIndex = (size/2).floor().toInt(); | |
var list1 = numbers.getRange(0, middleIndex); | |
var list2 = numbers.getRange(middleIndex, size-middleIndex); | |
return [list1, list2]; | |
} |
OlderNewer