« first day (402 days earlier)      last day (1133 days later) » 

1:15 AM
I think all of the arithmetic verbs should be fully atomic. I'm also a bit uneasy with giving verbs adverb-like overloads. Another opinion I have on this matter is that selfie can be further generalized as arg rotate :). Does it work that way in any apl dialects?
 
1:51 AM
@richie it'd be an adverb, not adverb-like
Intdiv, mod and bar are already not fully atomic
Could argue being fully atomic is overrated - matrices of arbitrary dimension can be represented by a flat list that's later cut, or a dict
I don't have a strong view on this btw but I like the idea of using tacits to get around scope limitations
 
2:33 AM
and once again i will lodge my objection to jamming unrelated functions onto primitives (% as self if atom else division.) exceptions like this create the impression that the language is an ad hoc patchwork. and such an impression would not be mistaken.
i will repeat a message i sent yesterday (arthur has often referred to me as his "conscience"):i favor whatever is intuitive and easy to understand, explain, remember, and apply. (those are separate but related properties.)

i'm not necessarily looking for what would result in the shortest expression. more code isn't necessarily bad code. i do worry that the attempt to pack as much meaning into as few symbols as possible will interfere with learnability, and therefore readability.

i prefer a small set of general rules (even if those rules leave out some cases for which there are "workaro
 
Note the goal here isn't to get shorter code - it's to reduce the importance of lexical scope
(Again, I don't think it's a good or bad idea - but it's an option)
 
i guess i don't understand why lexical scope is important. 'self' or 'o' or '.z.s' have all been suggested as the self-reference word. my preference is for 'self', but i could live with any one of them.
meanwhile, here's a puzzle: shakti has one type for all the functionals: lambdas, primitives, compositions, &c. write a function 'lambda' which returns 1 iff its argument is a lambda, else 0. (assume it takes only functionals.) why is this important? because only lambda functionals can be projected.
 
3:04 AM
@StevanApter last time I checked (a couple of days ago) primitives could now be projected - it was broken before. do you have a motivating example?
 
 
1 hour later…
4:16 AM
so for example:
2020.04.12 (c) shakti
 +[1;]
+[1;]
 +[1;][2]
3
 (1+)[2]
3
 
 
1 hour later…
5:40 AM
@StevanApter by scope i mean being able to refer to definitions within a nested lambda, eg:
 {a:2;{a+1}[]}[]
{a+1}
 ^
error: value
 
 
3 hours later…
ngn
8:49 AM
@StevanApter you're mixing up self (aka recur) and selfie
selfie is an informal name for j's ~ and apl's (f⍨A←→A f A)
 
ngn
8:59 AM
@StevanApter "why lexical scope is important" - to avoid polluting the global scope with things that don't belong there
 
k tech tree... may not finish but as a thought experiment am interested in how far one can get with k-strings (mostly) alone. feel free to contribute. much gratitude to ngn's open-source ngn/k code gist.github.com/chrispsn/b1020918a83a28ab8b4442d8aff8d1b4
 
ngn
@chrispsn nice :)
@chrispsn are you aiming for fast or short?
 
@ngn either! was thinking there could be multiple implementations shown
 
ngn
that version of prm is neither the fastest, nor the shortest
@chrispsn i use this
it returns flipped permutations, but even with an additional +, it's faster
for a short prm - maybe translate to k9 one of these
 
9:35 AM
thanks, added; will add combinations too
 
9:51 AM
@chrispsn there was a thread about rotate on apr/06/2019 on the mailing list
 
ngn
@chrispsn oops.. i've written something stupid there. 0#,0 is the same as !0.
should be 0#,,0
 
ngn
10:12 AM
slightly shorter, non-recursive, same performance: prm:{(,&y##*x),,'/x+/~x</!y}/(,0 1#0),1+!
faster: prm:{(,&y##*x),,/'x+/x>/-1+!y}/(,0 1#0),1+! (~250ms -> ~200ms for prm 10)
 
@ngn which dialect? in k9:
 p:{(,&y##*x),,/'x+/x>/-1+!y}/(,0 1#0),1+!
 p 3
0 0 1 1 2 2
1 2 2 1
0 2 2 0
 
ngn
@chrispsn ugh.. mistake. sorry.
@chrispsn p:{(,&y##*x),,/'+x+/x>/-1+!y}/(,0 1#0),1+!
 
10:35 AM
@ngn thanks! updated
 
11:02 AM
@ktye thanks! added. is rotate useful for implementation of other prims? gist.github.com/chrispsn/…
 
there was something about find (sustring) on hn which includes rotate.
i cannot find it, it was about x=/:y to produce a list of all matches, than rotate each by it's list index to line up all matches, than |/ to find cols with all 1. than & to return the locations.
 
@ktye was it a recent thread?
maybe geocar?
 
maybe a month ago, could be geocar, or it may have been in j or apl (because of rotate).
 
11:23 AM
added 'where'
lots of !#x es ;)
secret campaign to have !x return list indices
 
@chrispsn there is also decode: {{z+y*x}/[0;x;y]} (from k7 binary)
 
11:40 AM
@ktye thanks - i feel a little nervous including stuff from the binaries without permission. maybe it's small enough that it's irrelevant
 
it's not binary. it's from the output of strings, which per definition is text.
 
12:07 PM
a lot of the oK implementations use half-js, half-k fns github.com/JohnEarnest/ok/blob/gh-pages/oK.js
 
12:37 PM
got a better find? ideally would work for dicts too gist.github.com/chrispsn/b1020918a83a28ab8b4442d8aff8d1b4#find
 
12:58 PM
chrispn - you're right - that's new (projectability of primitives)
@ngn - thanks, i was mixing them up (never heard of "selfie")
 
Should 1+ match with +[1;] ?
Doesn't in both k7 and k9
 
2:05 PM
imo if you can coax the K interpreter into showing its internal definitions for anything it's fair game. IANAL but seems to me that it'd fall under provisions for reverse-engineering for compatibility, which is fair use.
 
2:21 PM
it's possible that there was prior art, but I think the brute odometer and graph traverse idioms in fun.k were discovered by me. I think Stevan said my formulation of "shape"

-1_#:'*:\

was also an original discovery, but it is limited compared to the K primitive- it implies an assumption that the structure is rectangular.
there are lots of amusingly horrific ways to define k primitives in terms of one another. One way to get enclose from join and take: (tacitly, even!) -1#(),
dyadic @ is naturally {x.,y}
one "primitive" that you cannot substitute is $[;;...], since it is a special form. Given cond, you can implement most of the adverbs in terms of the "while" form of over/scan.
 
2:36 PM
Can't you do the poor man's cond by abusing array indexing? e.g. (false;true)[cond]
 
@coltim In many cases, yes. But you can't use that trick to implement recursive calls because both subexpressions will be eagerly evaluated before the "conditional" part happens.
you _can_ do

cond f/

to conditionally evaluate f...
 
I'm unsure if this counts, but what about f:{x:((::;f)[x<10])[x+1]};? (k4)
 
ah, now that's interesting
 
2:55 PM
@chrispn: lambdas and non-lambda functions differ w.r.t. to projection. primitive projection is syntactic, lambda projection is not. e.g. {x+y}2 vs +[2;]. thus, one cannot write a general purpose 'apply' function - {{x y}/:[x;y]}.
"secret campaign to have !x return list indices." i've already sent my army into the field to have !x return count of x, since that contains all the information present in the index vector, which you can then get with !!x. now #x is freed up for other uses.
 
@StevanApter in oK all projection is semantic; everything will project:

{x,y}@2
{[x;y]x,y}[2;]
 
in k4 as well, but that's because + and +: are distinguished
the decision to let add and flip be determined by context essentially rules out a large class of metaprogramming solutions.
 
seems like a bad trade to me
 
ngn
3:10 PM
@JohnE prior art for "shape" (the d is there to limit it to a given depth) and i'm sure there've been others
what did you use before -1_#:'*:\?
 
ngn
@StevanApter that looks like it does a lot more than finding the shape
if i understand correctly, it tries to cut off at the depth where the array becomes ragged, while JohnE's assumes rectangular
 
3:26 PM
cutting off where it becomes ragged is how the K primitive work(s|ed)
 
ngn
4:11 PM
will there be an n f/:x and n f\:x in k9 (formerly n f/x and n f\x)?
 
ngn
4:31 PM
@chrispsn much faster permutations: {y;(,&(1+#x)##*x),(,/(&'~i=\i:!1+#x)@\)'x}/(,0 1#0),& but looks ugly because of the n f/:x workaround
 
you can just index the list given by \:, for example:
{2*x}\:[1]4
16j
Also, for scan:
4#{2*x}\:[1]
1 2 4 8j
 
ngn
@yiyus huh! i didn't expect that. thanks
@yiyus but that generates all powers of two until convergence (due to overflow) and then indexes into or takes from them
if you try powers of 3, it segfaults
 
4:47 PM
that's interesting. i noticed this worked while trying yesterday's new version, but did not have much time to play with it. it segfaults with powers of 3, and you get a WS error with {2+x}
probably a glitch
 
 
2 hours later…
7:17 PM
@ngn - that's right - at each recursion 'shape' determines whether all the counts are equal, and if so, records that number and continues.
 
 
3 hours later…
10:38 PM
john conway, dead of covid19
 
11:33 PM
@StevanApter {|}
 
11:54 PM
I wrote this shape function a few months back in k7
```s1:{*:'/-1_{(1=#?*x)&~&/{x~*x}'x 1}{(#:'m;m:,/x 1)}\(,#x;,x)}```
I took nsl's bshape as inspiration (thanks Stevan!) at first since k7 has no _f and it morphed into the above over time.
 

« first day (402 days earlier)      last day (1133 days later) »