Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct
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
/ grammar combinators in K | |
/ for longer description (in python), see: | |
/ http://tangentstorm.github.io/draft/wejalboot.py.html | |
/ -- misc helper functions ------------------------------------ | |
join:{[sep;strs] / join strs with 'sep' as delimiter | |
(#sep) _ ,/ sep,' strs} |
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. Self-Organising map | |
require 'math/lapack/geev' | |
require 'tables/csv' | |
require 'viewmat' | |
NB. closeall_jviewmat_ '' | |
NB. parameters: | |
N =: 30 NB. side of neuron map. (N -> (*:N) neurons) | |
ntrain =: 25 NB. number of training samples per class | |
niter =: 10000 NB. number of iterations | |
'a0 an' =: 25 1 NB. Starting and ending learning factor |
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
whence =: verb define | |
select. 4!:0 < y | |
case. _2 do. 'invalid name' | |
case. _1 do. 'name not defined' | |
case. 0;1;2;3 do. | |
index =. 4!:4 < y | |
select. * >: index | |
case. 0 do. 'name defined locally' | |
case. 1 do. > index { 4!:3'' | |
end. |
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
load 'viewmat' | |
gen_table =: 4 : '(0j1*(i: x)) +/ i: y' | |
fractal =: 1 : 0 | |
: | |
x u"0 (y +~ 30000 %~ 150 gen_table 150) NB. resolution and scale, not sure how to decouple them | |
) | |
collatz =: 4 %~ 2 + (7*]) - (2+5*])* 2 o. o. | |
is_bounded_c =: 4 : '((0: collatz^:x) :: 1:) y' NB. collatz |
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
s44 =: 4 4 $ 0 0 0 0 0 0 2 1 3 0 0 4 0 0 0 0 | |
box =: (] #"1 ] # ([: i. 2 # ])) | |
indices =: 3 : 0 | |
yy =. {. y | |
a =. yy #"0 i. yy | |
b =. |: a | |
c =. a ,/"0 b | |
) |
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
#version 330 core | |
//Sampler defaults to unit 0 which is where our texture is bound | |
uniform sampler2D tex; | |
in vec2 fuv; | |
out vec4 color; | |
void main(void){ |
h> (map sum)[[0..n]|n<-[0..10]
j] +/"1 i."0 >:i.11
j] +~^:5]1
h> let rfx f y = f y y ; pow = (\n f -> if n == 0 then id else f . pow (n-1) f) in pow 5 (rfx (+)) 1
j] +/~i.4
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
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 }, |
NewerOlder