« first day (404 days earlier)      last day (1131 days later) » 

12:55 PM
rng:&&0,
 
1:11 PM
@richie nice
'Where' is eerily common in short, fast solutions
@Traws i like this if we don't assume & or # are available
although it's not quite right for the zero case
 
1:34 PM
@chrispsn yes, it should be {-1+\x(1,)/`i$()}
 
@Traws @richie - added, thanks. If take exists then it looks like icsa's ({&x#1}) is a little faster, but i love that it only needs to use where, and list literal syntax gist.github.com/chrispsn/…
also worth noting k7 (but not yet k9?) deferred execution of !x - not sure how this whole thing should account for such cases
 
 
2 hours later…
3:49 PM
Another option for length is {y+1}/
 
4:13 PM
Scratch that that code is so wrong it's not even funny haha
 
Assuming the count of a scalar is 1, would 0+/{1}'(), work? (at least in k7)
 
Yeah that should work. The idea I wanted to express was 0{y;x+1}/
 
ngn
@coltim in k9 / is eachright and there's no way to give an initial value for reduce
but this could work: {y;x+1}/0,
 
4:29 PM
ooh, that's pretty clever!
 
ngn
not really. it's just start with 0, go through the elements and add 1 for each.
the only tricky bit is that you must force the function to be dyadic
 
I guess I expect / to "use" the input data, vs. it being a for loop on the count
(in other languages it'd be the difference between a for loop and a forEach loop)
 
4:57 PM
Here's where in k4/k7
w:{-1+,/l+!#l:~-1=!:',/,x}
Assumes ! Exists
 
 
3 hours later…
8:29 PM
It feels like a +\ soln could work for where
Or an index into the original array
 
9:22 PM
which is what 'k tech tree' has listed already
 
9:36 PM
looking for something that doesn't involve nested arrays
 
ngn
9:51 PM
@chrispsn {+/~(+\x)>\!+/x|:0} ?
still uses nested though :( what was that thing with step functions?
 
 (`step 0 2 3!"abc")@!4
"aabc"
 
ngn
thanks
 
@ngn at least there's no catenation
 
ngn
10:10 PM
seems it should work with step functions, but i'm running into bugs
{1+(`step(+\x)!!#x)@!+/x|:0}
@chrispsn {1+(`step(-1,+\x)!-1,!#x)@!+/x:0|$[x~*x;,;]x}
 
I've been tinkering with something you folks might find interesting. A compiler from a K subset to GLSL fragment shaders: beyondloom.com/tools/specialk.html
 
ngn
@JohnE cool :) dyalog:co-dfns = k:.. co-lambdas?
 
co-dfns aspires to solve the much more challenging task of general computation on a GPU. Special-k is just a nice concise k-flavored syntax and sugar for writing fragment shaders that draw pretty animations on the screen.
on the plus side, though, since I'm only using GLSL ES in WebGL it should theoretically run on just about anything that can handle a modern-ish browser. Some people have said it works in Chrome on Android
I might integrate this thing with iKe eventually. You could do some really crazy shit if you could define uniforms and have both a shader and general oK program communicating with it
 
ngn
10:33 PM
@JohnE i thought drawing pixels in iKe was strange. vector graphics and shaders should be more in the spirit of array languages.
 
well, when I first wrote iKe webGL was a lot less mature
 
ngn
@JohnE what about canvas?
 
iKe uses canvas. And it does have a vector drawing primitive
but the way you draw things in a shader program is completely inside-out from that perspective
 

« first day (404 days earlier)      last day (1131 days later) »