Skip to content

Instantly share code, notes, and snippets.

@rdm
rdm / tabledit.ijs
Created July 30, 2023 18:55
jqt: tab separated values file editor
NB. file editor
NB. design favors convenience over crispness
NB. (on close can restart and pick up where left off if J session remains active)
require'tables/dsv'
NB. default directory for file open
getfilename=: {{wd 'mb open1 "Select TABle file" *',y}}
NB. get/set commands
entering /mnt/c/cygwin64/home/15712/jsoftware/jsource/make2
jplatform64=linux/j32
CC=clang
compiler=/usr/lib/llvm-11/bin/clang
CFLAGS= -fPIC -fvisibility=hidden -fno-strict-aliasing -Werror -Wextra -Wno-unknown-warning-option -Wsign-compare -Wtautological-constant-out-of-range-compare -Wuninitialized -Wno-char-subscripts -Wno-consumed -Wno-delete-non-abstract-non-virtual-dtor -Wno-empty-body -Wno-implicit-float-conversion -Wno-implicit-int-float-conversion -Wno-int-in-bool-context -Wno-missing-braces -Wno-parentheses -Wno-pass-failed -Wno-pointer-sign -Wno-string-plus-int -Wno-unknown-pragmas -Wno-unsequenced -Wno-unused-function -Wno-unused-parameter -Wno-unused-value -Wno-unused-variable -ggdb -O0 -m32 -DPYXES=1 -DREADLINE -DUSE_LINENOISE -I../../../../mpir/include -m32 -msse2 -mfpmath=sse
clang -c -o state.o ../../../../libbacktrace/state.c -fPIC -fvisibility=hidden -fno-strict-aliasing -Werror -Wextra -Wno-unknown-warning-option -Wsign-compare -Wtautological-constant-out-of-ra
readmanifest=: {{
coerase([cocurrent)cocreate ''
0!:100 y
(;".)every nl 0
}}
manifests=: <@readmanifest"0 (#~ '/manifest.ijs' +./@E.S:0 ]){."1 dirtree '~addons'
manifestget=: {{ ({:"1 y){::~({."1 y) i. boxopen m }} (L:1)
addon=: 'FOLDER' manifestget
description=: 'DESCRIPTION' manifestget
@rdm
rdm / vm+instr.ijs
Created February 4, 2023 15:10
"Thinking in states" using slightly more idomatic J
NB. a rephrase of the J implementation at https://www.metalevel.at/tist/
instrs=: 9 33 1 1 2 1 4 1 3 0 2 1 12 30 3 1 3 0 7 4 1 3 0 2 1 6 4 0 9 8 3 1 15 2 4 13 2 14 0
st=: 0 {:: ]
is=: 1 {:: ]
pc=: 2 {:: ]
fp=: 3 {:: ]
next=: (>:&pc { is)
@rdm
rdm / purple-triangle.ijs
Created January 12, 2023 07:39
Where would console.log go?
webgl_close=: {{ wd'pclose'}}
wd bind{{)n
pc webgl; cc w webview;
pmove 0 0 300 300;
pshow;
set w html *
<html><head><title>test</title></head>
<script>
function run(){
console.log('hi');
sample=: {{)n
[D]
[N] [C]
[Z] [M] [P]
1 2 3
move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2
cocurrent'zip0'
NB. read from "single disk store only" zip files (zip64 standard)
rd=: 1!:11 NB. indexed file read
lend=: [:<.p.&256@(a.&i.)S:0 NB. numbers from little endian representation
plend=: {{
struct1=. (e.~ i.@{:) +/\0,m
struct1 {{
nums=. lend m <;.1 (#m) {.y
641 821763 2052486 3283209 4513932 5744655 6968330 7384979
4101780 8616342 9847065 11062407 11470084 11889288 12307231 6563232
10261138 13129634 12307854 14763522 5332517 10665633 15590439 16812177
3699242 17641001 18449285 9041326 19280688 19692171 9434927 1242263
8218925 20507564 20912668 13950760 14357798 21331876 2871064 2472986
6164515 20077453 17232027 16007731 16409012 4938930 12706576 15187243
18048669 18872369 1640341 13528339 21744054 22971575 23383093 23793336
24203577 24613818 25024059 25434300 25844541 26254782 26665023 27075264
27485505 27895746 28305987 28716228 29126469 29536710 29946951 30357192
30767433 31177674 31587915 31998156 32408397 32818638 33228879 33639120
/*
* testing involving real time is an integration test - high value, high cost
* these next two routines represent that interface
*/
const msDeadline= ms=> {
console.log('msDeadline',ms);
const deadline= ms+new Date().getTime();
return ()=>deadline < new Date().getTime();
};
/*
* testing involving real time is an integration test - high value, high cost
* these next two routines represent that interface
*/
const msDeadline= ms=> {
console.log('msDeadline',ms);
const deadline= ms+new Date().getTime();
return ()=>deadline < new Date().getTime();
};