Skip to content

Instantly share code, notes, and snippets.

tangentstorm / oK-bot.js
Created Sep 11, 2015
K5 bot for #learnprogramming and #jsoftware on freenode
View oK-bot.js
// An IRC bot for the k5 programming language,
// using oK from :
"use strict";
var irc = require('irc');
var ok = require('./ok/ok');
const MAXLINES = 8;
var client = new irc.Client('', 'oK-bot', {
channels: ['#jsoftware', '#learnprogramming']
tangentstorm /
Created Mar 10, 2022
simple command language parser for jprez in gdscript (godot).
# i wrote this, and it works, but then i decided to just use Godot's own Expression parser.
func _examples():
test('@title["the deck"]')
test('@show["jp-editor"; 0]')
test('@ed.xy[ 0 5]')
func test(cmd:String):
if cmd.begins_with('@'):
tangentstorm / animation.ijs
Created Aug 12, 2019
Basic animation in J
View animation.ijs
NB. Code from the "Basic Animation In J" video
NB. ------------------------------------------------------------------------
NB. animation demo
load 'viewmat'
wd 'pc w0 closeok' NB. parent control (window) named 'w0'
tangentstorm / ed.ijs
Last active Jul 29, 2021
A tiny editor in J
View ed.ijs
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)
tangentstorm / gramco.k
Last active Jul 8, 2021
Rough port of my grammar combinator thing to k3.
View gramco.k
/ grammar combinators in K
/ for longer description (in python), see:
/ -- misc helper functions ------------------------------------
join:{[sep;strs] / join strs with 'sep' as delimiter
(#sep) _ ,/ sep,' strs}
tangentstorm / parsers.ijs
Last active Jul 7, 2021
parser combinators for J
View parsers.ijs
NB. Parser Combinators for J
NB. The semantics here are heavily inspired by
NB. Allesandro Warth's ometa system:
NB. but implemented as parser combinators rather than a standalone language.
tangentstorm / asmvm.js
Last active Jul 2, 2021
ASM vm... This started as an attempt at a bootstrapping virtual machine, then I got caught up with the idea that bytecode could be human readable, and it probably got a bit out of hand.
View asmvm.js
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
tangentstorm / meld.js
Created Dec 2, 2020
meld a list of dictionaries into a smaller list of dictionaries
View meld.js
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 ( in idx) it = res[idx[]]
else { it = {id:}; idx[] = res.length; res.push(it) }
for (k of Object.keys(x)) if (k!=='id') it[k] = glue(it[k], x[k]) }
return res }
View catalan-1-filter.ijs
c =: '01' ([: +/ =)"0 _ ] NB. count 0 and 1
t =: {{(*/ <:/"1 c\ y) *. =/c y }} NB. the two rules
g =: {{'01' {~ #:i.2^2*y}} NB. generate the numbers
f =: {{y {~ I.t"1 y}} NB. filter by t
f g 3
tangentstorm / something4thy.js
Created Aug 2, 2013
something 4thy this way comes...
View something4thy.js
var b4 = (new function() { var EOF='\0',self = {
d:[], a:[], // data and auxiliary/return stack
defs:[],core:[],scope:[], // dictionary
base:10, // numbers
cp:-1, ch:'\x01',ibuf:[],wd:'', // lexer state
compiling:false,state:[],target:[], // compiler state
def : function (k,v){
var res=self.defs.length; self.defs.push(v); self.scope[0].push([k,res]); return res },