« first day (677 days earlier)      last day (858 days later) » 

6:33 AM
@ngn i think it should be designed to be useful for indexing, so whichever one would let the user easily pull out elements from a tree with the same shape
@ngn i'm struggling to understand how the result of multi-dim where can be applied without infix or square brackets
ideally someone could use this without knowing the structure of the data they're processing
so square brackets, infix etc don't work well - we need something that can consume the where result directly
so for example, here:
 m
("hello"
 "world")
 m'[1 0 1;0 1 4]
"wed"
 m' . (1 0 1;0 1 4)
("world"
 "hello"
 "     ")
i would have thought m' . would give the same thing as m'[...]
btw k9 and ngn/k give different results for a simper example:
l2021.01.10 3GB (c)shakti 2.0
 s:"hello"
 s@&s="l"
"ll"
 s'[&s="l"]
"ll"
ngn/k, (c) 2019-2021 ngn, GNU AGPLv3 - git.sr.ht/~ngn/k/blob/master/LICENSE
 s:"hello"
 s@&s="l"
"ll"
 s'[&s="l"]
-1 -1
and for the earlier m example, k7 and k9 give:
2019-09-25 14:44:44 2core 3gb avx2 © shakti l test
 m:("hello";"world")
 m'[1 0 1;0 1 4]
"wed"
 m' . (1 0 1;0 1 4)
m' . (1 0 1;0 1 4)
^
class error
>

(base) chris@chris-VirtualBox:~/k9web$ k9
l2021.01.10 3GB (c)shakti 2.0
 m:("hello";"world")
 m'[1 0 1;0 1 4]
"wed"
 m' . (1 0 1;0 1 4)
world
hello
hello
 
 
1 hour later…
ngn
8:12 AM
@coltim yes, `@ and `? are serialize and its inverse, like in k9
 
@ngn that was k7. k9 has no more ser.. in the free version afaik
 
ngn
@ngn sinful thoughts of writing docs are crossing my mind
 
do it!
 
ngn
@ktye that raises 2 questions: what is `@ now? and how does one serialize (or whatever it's called) stuff?
 
*2: r/w data
* means commercial
 
ngn
8:16 AM
the rest will be free?
 
`@3 4
^
!EAS
no idea what that is. crypto?
 
ngn
no, that's "aes"
 
an all-caps error msg from arthur? that must be severe
 
ngn
errors use ! again?
 
yes
@ngn ngn.bitbucket.io/k/… why are they different?
 
ngn
8:28 AM
@ktye have you read the one-line grammar?
for the last line: @[2 3] is a noun. it forms a projection of dyadic @ with 2 3 as the left arg. s' is applied to the projection.
Jul 6 '19 at 12:28, by ktye
You are right. It helps taking a look at the grammar:
E:E;e|e e:nve|te| t:n|v v:tA|V n:t[E]|(E)|{E}|N
I rewrote the parser.
you have read the grammar :)
 
so for brackets the arity of the verb must be explicit?
for me that is not a projection.
 
ngn
@ktye good question..
 
but that's ok. different readers/philosophers have different interpretations of texts
 
ngn
if i changed this to be implicitly monadic, we'd lose the ability to write +[x]y
 
so does k9: +[3]4
^
!rank
 
ngn
8:42 AM
well, k9 makes no distinction between + and +:
@ngn more importantly we'd lose +[;x]y
 
just make the projection explicit. i think that helps the reader too: +[3;]4
@ngn why? that works fine
the primitive is called with 2 arguments, so it's dyadic.
 
ngn
you're right
so why didn't i do this when i was working on the parser..
this breaks only 2 old golfs
 
ngn
9:11 AM
and for some reason it makes 1+/ display as +/[1;]
aha! the formatter itself was using ~[something]' :)
whew, done
@ktye they are still different but i hope you can see why
(@[2 3] correctly evaluates to `L)
@chrispsn what is string' in shakti?
 
ngn
9:42 AM
@chrispsn using the result from where is a bit more convoluted than i thought initially
here's an example that extracts all "l"-s and "L"-s from a 3d array: ngn.bitbucket.io/k/…
if the transposition is not too expensive: a ./:+i
 
10:03 AM
@ngn yes - hence why i thought it might be better for it to be transposed in the first place... but maybe there are other uses
@ngn "hello"'2 1 3 => "lel"
@ngn this is cool
maybe this is why & was kept flat? too hard to use in practice on arbitrary structures?
i still think it's useful though
might simplify implementation of odometer :) ngn.bitbucket.io/k/#ceWubqyDziubr
 
10:57 AM
^ and leave ! free to be !# on lists...
 
ngn
11:33 AM
@chrispsn nice but not fast enough to replace the current one
 
@ngn no. at least not without special-casing. still handy for k tech tree though. gist.github.com/chrispsn/b1020918a83a28ab8b4442d8aff8d1b4
 
 
3 hours later…
2:37 PM
@ngn I haven't wrapped my head around all the impacts, but I guess this removes some of the need for : (and the each-right trick of e.g. ,["ab",x]'"def")
 
ngn
@coltim i hope it didn't break too many of your golfs
 
@ngn no worries there! overall I think it's a good clarification (trying to see if there are any savings =P). 1 2 3&[0 5] is interesting
 
ngn
@coltim that's 1 2 3@&0 5
a term (verb or noun) followed by [ ] becomes a noun, so the & there doesn't take a left arg
 
yeh, it adds a byte in that instance
 
 
3 hours later…
5:20 PM
hmm, what's the shortest way to check if the absolute difference between the items of a 2-element list is 1?
 
ngn
@coltim a|-a:-/x afaik
 
(working on golfing {((#x)(+':1,)/1)?#'.=^(,/$!10)?x}. the tricky part is that I need the absolute difference due to = respecting the order of the input... this made me realize I can just sort the input up front
 
ngn
@coltim what's the challenge?
 
this one. trying to clean up one of my earlier golfs
I have it down to 39 with: {1=-/(+':1,)/[#x;1]?#'.=^(,/$!10)?x@<x}
there's potentially something with ,': 'ing the fib series, then doing ?,#'.=....
 
ngn
@coltim but there are non-numeric characters below "0" and above "9"
you could sort after testing for nulls
slightly shorter way to identify digits: ^(,/$!10)?x -> =/"0:"<\:x
 
5:40 PM
@ngn ooh that's clever!
ok I have 37: {(((#x)>+/)(+\|:)/!2)~#'.==/"0:"<\:x}
the "messy" (((#x)>+/)(+\|:)/!2)~ is still shorter
 
ngn
it might be better to generate all consecutive fibonacci pairs and search among them
92(|+\)\!2 /it overflows after step 92
i don't see any tests. does this look correct? ~^*(91(|+\)\1 0)?,#'.==/"0:"<\:x
(without the x, to make it a composition)
 
@ngn I compiled some here
I think the order can still throw things off
maybe {|/~^(91(|+\)\!2)?|:\#'.==/"0:"<\:x}?
 
ngn
ah, i should have reversed (|) after group by (=)
@coltim that fails on the 3rd test
 
oh, hmm. order matters even more! (non-numeric needs to be the smaller number)
 
ngn
this works afaict: ~^*(91(|+\)\1 0)?,#'.|==/"/9"<\:
well, with "/9"< instead of "0:"<
grr.. it breaks if the input starts with a digit :(
 
5:57 PM
ok these are better test cases
(first 5 are 1's, remaining are 0's)
 
ngn
6:11 PM
@coltim just one byte less than yours: ~^*(91(|+\)\1 0)?,-1+.#'=>/"/9"<\:"0a",
another byte: ~^*(1+91(|+\)\1 0)?,.#'=>/"/9"<\:"0a",
 
@ngn now it matches {(+\|:)/[(#x)>+/;!2]~+/'~:\=/"/9"<\:x} =P
 
ngn
ok, i give up :)
 
6:42 PM
@ngn ugh me too. that digit check trick is definitely applicable elsewhere though!
it also makes me wonder why e.g. (1 2;3 4;5 6)?,1 2 returns ,0 instead of just 0
 
ngn
@coltim i thought it's consistent - the right arg is a list, so it returns a list
 
@ngn is this one of those floating/grounded things? =P
 
ngn
@coltim k doesn't distinguish between rank and depth, so it doesn't have problems of that kind
if we consider "shape" to be either empty (for an atom) or a single int (for a list of any type), we could say that "find" returns a result of the same shape as its right arg
 
@ngn hmm. I guess k4's in weirdness also applies to ?
 
ngn
maybe in k4, but not in my impl
if k had enclosed scalars like apl (⊂⍵), you would be able to do (1 2;3 4;5 6)?⊂1 2 and get back an atom
but they've been simplified away because eachleft and eachright can replace most of their uses
 
6:59 PM
yeh, I can see there being a tradeoff between consistency and tactical utility
 
ngn
7:49 PM
mini-challenge: can you spot the new feature? :) ngn.bitbucket.io/k/#cU5PHXNYh7uVRgA==
 
@ngn hmm constant folding?
 
ngn
@coltim yes!
 
nice =)
 
8:05 PM
@ngn what do you fold? e.g. not +/1 2 3 or &1 2
 
ngn
@ktye only one or two simple cases as a proof that it works
verb/ and longs+longs (verb/ was already there)
 
@ngn what has side-effects? variables, rand, io, sth else?
 
ngn
@ktye errors
 
e.g. 1 2+1 2 3? would that hurt to be a parse error?
 
ngn
also, you probably don't want !10000000 (without the progressions optimization) to be const-folded
@ktye i'd rather leave that as a runtime error. there are legitimate reasons one might want that - testing, auto-generated code..
@ktye my most desired use is for lists like (0 1;2 3)
 
8:14 PM
in my current version, i intern all constants, so they exist only once globally. also derived functions, e.g +//
 
ngn
@ktye interning everything sounds like it would be slow
 
@ngn only for parsing. exec should be faster. no?
 
ngn
@ktye only for parsing might be ok.. idk
 
it's done when the parser creates byte code.
 
9:13 PM
@ngn it's been pointed out that here (a'). i gives the same result as ((#*i)#,a)@'/i, in other words it's easier to use than i had feared
 
ngn
@chrispsn not in ngn/k
 
in the examples i posted earlier i was thrown by a' . x not working... when of course . sees a' as a verb (because of the adverb), not a noun. so brackets are required
 
ngn
@chrispsn huh! i thought i'd reserved that for in. evidently not :)
 
aside: in not having its own glyph is a big shortcoming of k imo
it comes up too much to not get a spot
(or has)
 
ngn
@chrispsn similar to this from earlier today
@chrispsn would haystack'needle be bad?
or maybe the same with ':
 
9:23 PM
@ngn it's good imo, as long as it doesn't break the above use of deep where
having has on ' and bin on ': was elegant
but again, if it breaks deep where, we need another solution
 
ngn
deep where ("dhere"? by analogy with "amend-dmend") is not that common
 
i'm also concerned if (a'). i doesn't work when a is flat
& would need to return a list of lists for the flat case, which is not very elegant for the common case
maybe monadic % is deep where (free atm in k9)
@ngn it's going to come up when we have multi-dimensional data which i'm guessing will mostly arise when applying each-left and each-right
 
ngn
@chrispsn if it's rectangular there's another easy way to do it: s\&,/data where s is the shape
s:-1_#'*:\x or whatever it is in k9
 
@ngn yes, but this avoids the raze - it feels more direct
 
ngn
true
 
9:36 PM
your analogy to amend/dmend is a good one
 
10:20 PM
@ngn I made a bad/non-performant implementation of find-and-replace: {{$[^i:*((#y)'x)?,y;x;,/@[(0;i;i+#y)_x;1;:;z]]}[;y,();z]/x}. it works on various data types but only for lists. probably would need more checks
 
ngn
@coltim ah, i remember, you suggested find-and-replace for ?[x;y;z]
@coltim is this really useful for anything other than strings?
string replace is z/y\x
 
@ngn the only thing that jumped to mind was editing boolean runs. came up when I was trying to make a more vectorized string search
@ngn well if you put it that way... yep! lol
 
10:50 PM
(as an aside I think ? is my favorite primitive. mostly because it's a way to relate otherwise disparate sets of data. given an arbitrary A and B, I guess it and match are the (only?) primitives that can reliably give you information about how they relate to each other)
(honorary mention to ^ and ,)
 
ngn
indeed ? seems very fundamental
many other "primitives" use it, for instance dict lookup is v@k?x
 
yeh, and in/except/inter
can it ever throw a 'len error? o_0
 
ngn
in apl the old way to get uniq was (the equivalent of) x@&(!#x)=x?x
@coltim find? i don't think
random can
 
11:10 PM
@ngn a regex-style extension to this (or join/split) would be interesting
 
ngn
i would leave regex to the libraries :)
 
11:27 PM
@ngn building off this, I think a basic implementation of k4's ss is {(-#y)+\(#y)+#'-1_y\x}
 

« first day (677 days earlier)      last day (858 days later) »