Published
Edited
Oct 17, 2018
1 fork
Insert cell
Insert cell
/* viewof a = render(_.range(128)) */
viewof a = render(mapmov_mode_128())
Insert cell
Insert cell
viewof b1 = render(skew(b))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
skew = genSkew(16, false, false)
Insert cell
deSkew = genSkew(16, true, false)
Insert cell
skewPlus1 = genSkew(16, false, true)
Insert cell
deSkewPlus1 = genSkew(16, true, true)
Insert cell
genSkew = (cols, reverse, plus) => arr => {
const len = arr.length;
const rows = Math.ceil(len / cols);
let res = [];
for (let row = 0; row < rows; row++) {
const extra = plus ? (row / cols) |0 : 0;
for (let col = 0; col < cols; col++) {
const newCol = (col + row + extra) % cols;
if (reverse) {
res[row * cols + newCol] = arr[row * cols + col];
} else {
res[row * cols + col] = arr[row * cols + newCol];
}
}
}
return res;
}
Insert cell
mapmov_mode_128 = () => { // FIX 127???
let res = [];

let did_activate = 0;
let idx = 0;
for(let sc = 1; sc < 1024; sc++) {
if((sc & 0x1) == 0) {
if( sc < 130 || sc > 896) {
res[sc] = idx++;
}
}
}
return res;
}
Insert cell
sinverse = arr => {
let res = [];
arr.map((e, i, arr) => {
res[(arr.length - i) % arr.length] = e;
})
return res;
}
Insert cell
deMapper = ((arr, demap) => {
let res = [];
demap.map((e, i) => {
res[i] = arr[e];
});
return res;
})
Insert cell
deMapperMagic = arr => {
let res = [];
arr.map((e, i) => {
if (e !== undefined) {
res[e] = e;
}
})
return res;
}
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more