This file contains hidden or 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
package avl | |
type Compareable interface { | |
Compare(Compareable) int8 // 0 equal, -1 less than, 1 greater than | |
} | |
type Node struct { | |
Data []Compareable // duplicates allowed, data stored as array | |
Balance int8 // negative left heavy, positive right heavy | |
Link [2]*Node // 0 left, 1 right |
This file contains hidden or 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 ctoi(x, y) { | |
return { | |
x: x-y, | |
y: (x+y)/2, | |
} | |
} | |
function itoc(x, y) { | |
return { | |
x: (2*y+x)/2, |
This file contains hidden or 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
This is free and unencumbered software released into the public domain. | |
Anyone is free to copy, modify, publish, use, compile, sell, or | |
distribute this software, either in source code form or as a compiled | |
binary, for any purpose, commercial or non-commercial, and by any | |
means. | |
In jurisdictions that recognize copyright laws, the author or authors | |
of this software dedicate any and all copyright interest in the | |
software to the public domain. We make this dedication for the benefit |
This file contains hidden or 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
const UINT32_MAX_VALUE = 0xFFFFFFFF | |
class BigNum { | |
private _positive!: boolean | |
private _limbs!: Uint32Array | |
constructor(positive: boolean | string = true, limbs: Uint32Array | number[] = []) { | |
if (typeof positive === 'string') { | |
return BigNum._fromString(positive) | |
} |
This file contains hidden or 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
/* | |
expression = term {('+' | '-') term} | |
term = factor {('*' | '/') factor} | |
factor = base ['^' factor] | |
base = ['-'] value | |
value = number | '(' expression ')' | |
number = integer ['.' fractional] | |
integer = '0' | onenine {digit} | |
fractional = digit {digit} | |
onenine = digit - '0' |
This file contains hidden or 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
[ | |
main() { | |
return print(fib(10)) | |
} | |
fib(n) { | |
if (n == 0) { | |
return 0 | |
} else if (n == 1) { | |
return 1 |
This file contains hidden or 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
/** | |
* Frazier's Object Modeling Language (FOML) | |
* | |
* FOML is a superset of JSON with... | |
* 1. Bash style comments | |
* 2. Root object curley braces are optional (each FOML document describes a single object) | |
* 3. End of line commas are optional, trailing commas are allowed | |
* 4. Colon (:) and equal (=) are interchangeable | |
* 5. Colon/equal is optional for object and array assignment | |
* 6. Simple property names do not require quotes (alphanumeric and _-.$@ characters only) |
This file contains hidden or 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
const make_regexp = function(str, fl) { | |
return new RegExp(str.replace(/\s/g, ''), fl) | |
} | |
const rx_number = make_regexp(`^(?: | |
0 (?: | |
b [01]+ | |
| o [0-7]+ | |
| x [0-9 A-F]+ | |
| \\. [0-9]+ (?: e [+\\-]? [0-9]+ )? |
This file contains hidden or 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
const operations = { | |
'+': { | |
precedence: 1, | |
handler: (x, y) => x + y, | |
}, | |
'-': { | |
precedence: 1, | |
handler: (x, y) => x - y, | |
}, |
This file contains hidden or 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 AnimationLoop { | |
constructor({ update, render, panic, tickRate = 30, autoPause = true }) { | |
this.update = update | |
this.render = render | |
this.panic = panic ?? (() => this.delta = 0) | |
this.frameID = null | |
this.lastFrameMs = 0 | |
this.lastFpsMs = 0 | |
this.frameCount = 0 | |
this.fps = 60 |
OlderNewer