« first day (690 days earlier)      last day (845 days later) » 

8:42 AM
could k need apl's squad-indexing? that is, writing the index on the left. x i works without @. which could be used the other way: (x i)~i@x
i know that breaks things. what do you think?
 
 
2 hours later…
10:51 AM
first-filter kinda does this:
 *(2=!#)#"durian"
"r"
but i agree, i wonder how k flow would be impacted if @ and ? had x and y reversed
unrelated - cool new k9 toy:
l2021.01.25 3GB (c)shakti 2.0
 (#')!" "\"apple banana car ant durian"
3|("car";"ant")
5|,"apple"
6|("banana";"durian")
in other words (f)! or perhaps 'key by'
as usual it works with exprs:
 (:b)![[]a:1 2 3 4;b:1 2 1 2]
1|[[]a:1 3;b:1 1]
2|[[]a:2 4;b:2 2]
between this and (f)#_^ i get the feeling tacit programming in k9 is stronger than previous k designs
 
ngn
11:29 AM
no strong opinion from me, but two things to consider:
* lang ergonomics - which arg is more likely to be a more complicated expr, possibly requiring parens? ofc, we'd like that arg to be on the right
* mem reuse - does the length of the result match that of an arg? if yes, the arg can theoretically be recycled when refc drops to 0 and bit widths match. unless something significant has changed recently, k9 tries to do that only for the right arg (as i demonstrated once in the google group long ago)
@chrispsn also *2_"durian"
 
11:48 AM
@ngn good point, though this won't work if there's multiple indices (strictly speaking neither will the filter variant since order is not the same)
 
12:01 PM
Is there an equivalent to APL's <\ in K? (flip all 1s after the first 1 in a boolean vector)
 
@ngn do you do that too, reuse memory on right arg only?
 
ngn
@ktye no, generally (but not always) i try to reuse what's reusable
@rak1507 probably not as short. k scans are straightforward - O(n) and left-to-right
 
yeah
 
ngn
@rak1507 is this short enough? {x*1=+\x}
 
Yep
 
ngn
12:15 PM
@rak1507 also: >/'|',\
 
Could 'cut' help here?
Or amend
 
ngn
@chrispsn how?
 
can you do a b←foo in k?
 
I'll take a look in 7hrs or so
 
ngn
@rak1507 (a;b):foo
 
12:18 PM
thanks
 
12:35 PM
@ngn did you ever end up porting dzaima's collatz? I did to this {**{~1=#*x}{(i;a):x;(i@&m;a@&m:(+/'+m*1=+\'m:a=/:?a)*~1=a:m+(a*1+5*m:2!a)%2)}/2#,1+!x}
 
12:53 PM
Why remove? It was helpful
 
@rak1507 maybe he just optimized his, not ported mine
 
Oh true
 
ngn
@dzaima i ported yours, but i haven't updated it on sr.ht yet
 
ah
 
I didn't port the 20% speedup because it looked a lot more complex
My unique mask is probably very slow as well
 
ngn
12:56 PM
@rak1507 that's the hardest part
 
@rak1507 the 20% speedup is to space out calling the unique mask. you'd then probably have a much bigger boost than 20%
 
@ngn yeah, I did {+/'+m*1=+\'m:x=/:?x} which is probably slow
@dzaima oh yeah maybe, hm
might try it later
 
ngn
here's my port of dzaima's solution:
g:{x[1]:p+-2!x[1]*1+5*p:2!x[1]
   x:x@\:<x[1]
   x:(+/1=x[1])_'x
   x@\:&-1>':x[1]}
f:{**(1<#*:)g/2#,1i+!x}
x is the pair i a from dzaima's
≠⍵ is: sort a and i by a, and use >': (greater than each prior) to get the boolean mask
and it's convenient to drop all 1s between these two steps
 
2:00 PM
@ktye it does seem a bit tricky depending on how far this extends. like would it be possible to do e.g. list@func? mentally parsing it would be a bit more involved since you'd have to be on the lookout for leading @'s... I guess a direct replacement for x@<x isn't necessary as those could just be x[<x] or something
@chrispsn I'm still waiting on those (expr)< and (expr)> overloads =P
@rak1507 I like this boolean list idioms, but for some reason I thought translating them to k was just a matter of doing `{y<x}`. I guess those are their own "class"
@chrispsn I guess an amend version could be {@[^x;x?1;1+]}
 
2:17 PM
i overloaded x@f as f#x. if f is niladic and x is a dict(table) it acts within it's environment:
d:`a`b!(!10;5+!10); d{a>5} is the same as: {a>5}#f which is d@\:&(d`a)>5
computed columns are f#d where f returns a dict instead of a boolean mask:
{`sum`diff!(a+b;a-b)}#d
 
ooh, interesting
I guess to @ngn's point, are there examples where x@f has a bunch of additional stuff to its right? like I guess you could project some args, or maybe have some conditional logic returning differing functions, but I don't see how you would have a long chain of e.g. monadic functions the way you "normally" do
 
 
3 hours later…
5:01 PM
If it would extend to more than just functions/expressions, I could see it enabling some tricks like 0@x to get the first item
 
@coltim that's what i was asking for. first is simple, but second would be 1@x instead of *1_x. But i think flipping @ is too much confusion, also for derived functions.
 
@ktye yeh, @'s use to verb-ify what I call noun-verbs (i.e. projected functions, lambdas, etc.) is probably its chief use (and is relatively fundamental)
but I don't think using bracket notation is that bad. unless there are cases that doesn't cover
another question is how much it overlaps with the dyadic commute use cases
 
6:05 PM
just realized that there is a debian package aplus-fsf. it even runs on wsl. did you ever try?
 
ngn
hah
"Copyright (c) 1990-2008 Morgan Stanley. All rights reserved."
how did it end up in debian?!
 
aplusdev.org/index.html "its freely available under gpl"
 
ngn
then it's not "all rights reserved"
 
you have to type $mode ascii, than this works +/iota 5
 
ngn
nice
it probably uses a character set of its own, i can see unicode question marks in error msgs
 
6:15 PM
yes, it's an older encoding.
 
 
2 hours later…
8:12 PM
TIL I'm apparently not the only person who uses durians as a test case when creating bogus data to test something
 
9:03 PM
IIRC there's an emacs mode package for it in debian that sets the font up.
yep, aplus-fsf-el
 
9:24 PM
@JohnE haha. it's the first one that comes to mind for the 'd' slot when listing fruit
 
10:05 PM
exactly!
("apple";"banana";"cherry";"durian")
 

« first day (690 days earlier)      last day (845 days later) »