Inaft/Wishlist: Difference between revisions

From triplescripts.org wiki
Content added Content deleted
(consider notebooks)
 
(example doesn't need a full-text code snippet)
 
Line 1: Line 1:
* Need a trivial way to create a self-contained notebook, given small-ish repo. The point would be to obviate the need to set up a project, etc—once you have the notebook, you have everything. (Likewise, consider a way to ingest these notebooks and convert them to Inaft-style tests.) For example, consider if we wanted to demonstrate the following polyline decoding routine:
* Need a trivial way to create a self-contained notebook, given small-ish repo. The point would be to obviate the need to set up a project, etc—once you have the notebook, you have everything. (Likewise, consider a way to ingest these notebooks and convert them to Inaft-style tests.) As a basic example, consider if we wanted to demonstrate a [https://developers.google.com/maps/documentation/utilities/polylinealgorithm polyline decoding] routine.

<pre>
function decode(encoding) {
let points = [];

let latitude = 0;
let longitude = 0;

let ax = 1;
let bitMargin = 0;
for (let i = 0, n = encoding.length; i < n; ++i) {
let bits = encoding.charCodeAt(i) - 0x40;
ax += bits << bitMargin;
bitMargin += 5;

if (bits < 0x1F) {
latitude += (ax & 1) ?
~(ax >> 1) :
ax >> 1;

ax = 1;
bitMargin = 0;
while (++i < n) {
let bits = encoding.charCodeAt(i) - 0x40;
ax += bits << bitMargin;
bitMargin += 5;

if (bits < 0x1F) {
longitude += (ax & 1) ?
~(ax >> 1) :
ax >> 1;
break;
}
}

points.push([ latitude * 1E-5, longitude * 1E-5 ]);

bitMargin = 0;
ax = 1;
}
}

return points;
}
</pre>

Latest revision as of 21:10, 18 March 2023

  • Need a trivial way to create a self-contained notebook, given small-ish repo. The point would be to obviate the need to set up a project, etc—once you have the notebook, you have everything. (Likewise, consider a way to ingest these notebooks and convert them to Inaft-style tests.) As a basic example, consider if we wanted to demonstrate a polyline decoding routine.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.