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
struct Foo(uint); | |
fn main() { | |
enum Bar { Baz(Foo) }; | |
let x = Baz(Foo(4)); | |
fn foo(_bar: uint) -> Foo { Foo(3) } | |
match x { | |
Baz(foo(x)) => println!("{:?}", x) | |
}; |
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
fn main() { | |
fn map<F, T, A>(option: Option<T>, f: F) | |
-> Option<A> | |
where F: FnOnce(T) -> A { | |
match option { | |
None => None, | |
Some(value) => Some(f(value)), | |
} |
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
// | |
// btree.rs | |
// Nif Ward | |
// 10/24/13 | |
// | |
// starting implementation of a btree for rust | |
// inspired by github user davidhalperin's gist | |
//What's in a BTree? |
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
// XXX should be standard (and named clone, after Java?) | |
Object.prototype.copy = function () { | |
let o = {} | |
for (let i in this) | |
o[i] = this[i] | |
return o | |
} | |
// Containment testing for arrays and strings that should be coherent with their iterator. | |
Array.prototype.contains = String.prototype.contains = function (e) { |
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
var flatten = x => x.reduce((a, b) => a.concat(b)); | |
function transform(x) { | |
if(typeof x === 'string') | |
return [x]; | |
var {color, italic, translate, using, text} = x; | |
if(color) | |
return [['c', color, ...transform({italic, translate, using, text})]]; | |
if(italic) | |
return [['i', ...transform({translate, using, text})]]; | |
if(translate) |
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
function A() { | |
this.type = 'a' | |
} | |
module.exports = A; | |
var B = require('./b.js'); | |
A.prototype.delete = function deleteA(callback) { | |
var self = this; | |
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
Imports { | |
Import KERNEL32.dll_GlobalGetAtomNameA(ATOM,LPSTR,INT)@0x455080 | |
Import KERNEL32.dll_GlobalDeleteAtom(ATOM)@0x455084 | |
Import KERNEL32.dll_lstrlenA(LPCSTR)@0x455088 | |
Import KERNEL32.dll_lstrcpyA(LPSTR,LPCSTR)@0x45508c | |
Import KERNEL32.dll_GetProfileStringA(LPCSTR,LPCSTR,LPCSTR,LPSTR,UINT)@0x455090 | |
Import KERNEL32.dll_GetModuleHandleA(LPCSTR)@0x455094 | |
Import KERNEL32.dll_LocalAlloc(UINT,SIZE_T)@0x455098 | |
Import KERNEL32.dll_GlobalAddAtomA(LPCSTR)@0x45509c | |
Import KERNEL32.dll_LocalFree(HLOCAL)@0x4550a0 |
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
/// <summary> | |
/// Prompt the user to take a photograph to scan for a barcode. | |
/// </summary> | |
/// <param name="callBack">Method to invoke with the scan results.</param> | |
public void ScanCode(Action<IBarcodeResult> callBack) { | |
WP7BarcodeManager.ScanBarcode(ProcessBarcode); | |
_callBack = callBack; | |
} | |
/// <summary> |
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
function refuel() | |
if turtle.getFuelLevel() > 10 then | |
return true | |
end | |
for i=1,16 do | |
turtle.select(i) | |
if turtle.refuel() then | |
return true | |
end |
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
'183-559160438423-354467135967-54671620\n\ | |
84-113162777230260820483516--75476325641492692197865144648927723647584\n\ | |
65-2565125015350753326712-3274761771-0\n\ | |
516-526032531125-3333251474747-37475320\n\ | |
31-0526-765730-6176261251677772576501\n\ | |
532-52270754776507777271212563371151676553776-61557505576700-73702\n\ | |
576-65715057275-62116571-07710267775\n\ | |
53-5656327-7-627720\n\ | |
73-753612736572575747-763150335-32'.split('\n').forEach(function(x) { | |
var hex = x.split('-').map(function(x) { |