Skip to content

Instantly share code, notes, and snippets.

@Andruj
Andruj / binary_search.dart
Created August 23, 2016 03:38
An implementation of binary search in Dart.
search(List list, int value, int min, int max) {
if(min > max) {
return null;
}
final int mid = (max + min) ~/ 2;
if(value < list[mid]) {
return search(list, value, min, mid - 1);
}
@Andruj
Andruj / peaks.dart
Created August 23, 2016 03:16
An implementation of the peaks problem in Dart.
// Must have be non-empty.
peaks(list) {
if(list.length == 1) {
return list.first;
}
if(list.length == 2) {
return list.reduce((prev, curr) => curr >= prev ? curr : prev);
}
@Andruj
Andruj / merge_sort.dart
Created August 23, 2016 03:08
An implementation of merge sort in Dart.
List merge(List first, List second) {
if(first.isEmpty) {
return second;
}
if(second.isEmpty) {
return first;
}
if(first.first <= second.first) {
@Andruj
Andruj / ScriptingLanguageSpec.md
Last active November 14, 2015 04:00
A idea I had for a compile-to-js scripting language, primarily dealing with streams and file processing.

A Node Scripting Language (TB Named)

Variables

// Traditional JavaScript Primitives
$1 = [1,2,3,4]
$2 = 'String'
$3 = true