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
{deck} | |
version:1 | |
card:0 | |
size:[512,342] | |
name:"itemlist.deck" | |
{card:home} | |
{widgets} | |
itemlist1:{"type":"contraption","size":[400,161],"pos":[13,30],"def":"itemlist","widgets":{"label":{},"item_text":{},"items":{},"bnw":{},"bgo":{},"run_event":{},"slider1":{},"bpr":{},"bnx":{},"brm":{},"bup":{},"dn":{}}} |
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
// sh.mjs: javascript shorthand | |
// array helpers (apl/j/k) | |
export const id=x=>x | |
export const af=(n,x)=>Array(n).fill(x) // TODO: make this 'afl' or 'fil' (aa?) | |
export const ii=(n,f)=>{for(let i=0;i<n;i++)f(i)} | |
export const im=(n,f)=>af(n,0).map((_,i)=>f(i)) | |
export const ia=(n,f)=>im(n,id) | |
export const at=(a,ixs)=>ixs.map(i=>a[i]) | |
export const io=(xs,ys)=>ys.map([].indexOf.bind(xs)) |
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
customElements.define('ts-list', class extends HTMLElement { | |
static observedAttributes = ['ix'] | |
constructor() { super(); this.ix=0 } | |
connectedCallback() { | |
let sh = this.attachShadow({mode: 'open'}) | |
sh.innerHTML=` | |
<slot></slot> | |
<button id="up">^</button> | |
<button id="add">+</button> | |
<button id="dn">v</button>` |
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
let set=(o,k,v)=>{let r={...o}; r[k]=v; return r} | |
let gs=k=>(x,y)=> y===undefined ? x[k] : set(y,k,x) | |
let mb=gs('mb'), // match bit | |
ib=gs('ib'), // input buffer | |
ix=gs('ix'), // index into input buffer | |
ch=gs('ch'), // current character (ib[ix]) | |
mk=gs('mk'); // start index of current token | |
let s0=()=>({mb:0,ib:'',ch:'',ix:-1,mk:-1}) | |
on=s=>ix(0,ch(s[0],ib(s,s0()))) | |
m1=s=>mb(1,s) // match |
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
Class { | |
#name : #GsEllipse, | |
#superclass : #GsObject, | |
#instVars : [ | |
'radius', | |
'position' | |
], | |
#category : #GameSketchLib | |
} |
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
# i wrote this, and it works, but then i decided to just use Godot's own Expression parser. | |
# https://docs.godotengine.org/en/latest/tutorials/scripting/evaluating_expressions.html | |
func _examples(): | |
test('@title["the deck"]') | |
test('@show["jp-editor"; 0]') | |
test('@ed.xy[ 0 5]') | |
func test(cmd:String): | |
if cmd.begins_with('@'): |
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
NB. Core logic for a tiny editor in J. | |
NB. No select/copy/paste (in this gist), but it does support multiple cursors. | |
NB. This started as the code for editing a single line of text, but I'm now | |
NB. using three copies simultaneously: one for a single token, one for | |
NB. boxed tokens on a line, and one for boxed lines in a buffer. | |
coclass 'ed' | |
init =: {{ | |
B =: '' NB. the buffer to edit. | |
C =: 0 NB. cursor position(s) |
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
clear'' | |
NB. Parser Combinators for J | |
NB. | |
NB. The semantics here are heavily inspired by | |
NB. Allesandro Warth's ometa system: | |
NB. | |
NB. http://tinlizzie.org/ometa/ | |
NB. | |
NB. but implemented as parser combinators rather than a standalone language. | |
NB. |
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
const DATA=0, CALL=1, WORK=2, TEMP=3 | |
class Worker { | |
vm = null // virtual machine | |
w = 0 // worker number | |
f = 0 // function pointer | |
e = 0 // execution pointer | |
t = 0 // current token in function |
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
glue = (x,y) => x === undefined ? y : Array.isArray(x) ? x.concat(y) : [x,y] | |
function meld(xs) { | |
let idx = {}, res = [], it | |
for (x of xs) { | |
if (x.id in idx) it = res[idx[x.id]] | |
else { it = {id: x.id}; idx[x.id] = res.length; res.push(it) } | |
for (k of Object.keys(x)) if (k!=='id') it[k] = glue(it[k], x[k]) } | |
return res } |
NewerOlder