- To set up a useful, non-toxic Io base environment for development.
- To promote (and simplify) the better practices.
- Complete knowledge of scoping.
- Embedded docs.
- Testing.
sub vector-to-unit( @vec ) { @vec >>/>> sqrt( [+] @vec >>**>> 2 ) } | |
sub cross-product( @v1, @v2 ) { | |
( @v1[1,2,0] >>*<< @v2[2,0,1] ) | |
>>-<< | |
( @v1[2,0,1] >>*<< @v2[1,2,0] ) | |
} | |
sub surface-to-normal( @a, @b, @c ) { | |
my @b2 = @b >>-<< @a; | |
my @c2 = @c >>-<< @a; | |
my @normal = cross-product( @b2, @c2 ); |
function! BrightHome() | |
let s:col = col(".") | |
normal! 0 | |
if s:col == col(".") | |
normal! ^ | |
endif | |
endfunction | |
nnoremap <silent> <Home> :call BrightHome()<CR> |
let ( -- ) x y = | |
let step_y = match y > x with | |
| true -> ( fun n -> n - 1 ) | |
| false -> ( fun n -> n + 1 ) | |
in | |
let rec mklist x y ll = | |
if x == y then y::ll | |
else mklist x (step_y y) (y::ll) | |
in |
pushpath () { export PATH=${PATH}:${1}; } | |
# example: $ pushpath ~/bin |
// dumb test for int-ness, since Io doesn't have ints | |
// rather than being cheeky and doing Integer := Number clone | |
Number isInt := method(self == self roundDown) | |
countAndSumLobbyIntegers := method( | |
_ := Lobby slotNames select(x, | |
(Lobby getSlot(x) type == "Number") | |
) map(x, Lobby getSlot(x)) select(x, x isInt) | |
("There are " .. (_ size) .. " integer Numbers in Lobby") println |
// mostly a guess: | |
OperatorTable addOperator(":", 13.5) | |
// : is a key-value pair (list) constructor on sequences: | |
Sequence : := method(a, return list(self, a) ) | |
Message : := method(a, return list(self, a) ) | |
Map curlyBrackets := method( | |
env := call sender clone | |
x := Map clone |
/* Unsafe version: | |
List squareBrackets := method( | |
call message arguments clone map(x, | |
call sender doMessage(x) | |
) | |
) | |
*/ | |
// Safe version: | |
List squareBrackets := method( |
// Work in progress, code coming soon: | |
Io> match(1) [2: 5, 4: 2, 1: "yay"] | |
==> yay | |
Io> match(2) [2: 5, 4: 2, 1: "yay"] | |
==> 5 | |
Io> a := 10 | |
==> 10 | |
Io> match(a) [2: 5, 4: 2, 10: "yay"] | |
==> yay |
Regex | |
GrepRole := Object clone do( | |
grep := method(x, | |
self split("\n") select( | |
matchesOfRegex(x) map(k, k) size > 0 | |
) map(k, k) | |
) | |
) |