« first day (2661 days earlier)      last day (10 days later) » 

12:40 AM
@Silas I think the result can be fed to iota underbar
So it appears to be something useful when looking for the inverse of it
 
 
10 hours later…
11:00 AM
what's an APL-y glyph for Group?
also, is there an easy way to convert between Partition and Group's arguments?
 
11:12 AM
@RubenVerg What does it do?
 
 
1 hour later…
12:36 PM
@Adám it, uhh, places elements of an array in a nested array in the positions marked by another array
that's an awful description
 
Ah, what should have done.
 
what's the Group equivalent of the split on element fork pattern?
@Adám it seems much easier to implement so I was thinking maybe of adding Group and then implementing Partition on top of it by converting the representations
 
@RubenVerg ⍺×+\⍺ as left argument.
There's really no reason to have Partition. Partioned enclose is nice, though.
Remember to make them leading-axis instead of the current trailing-axis.
 
could work?
@Adám you're suggesting putting Group instead of Partition?
 
@RubenVerg Yes. They basically the same, except that Partition interprets 1 1 1 2 2 2 1 1 1 as three groups, while Group merges first and third element.
This assumes you keep the "0 discards" rule.
This reminds me: could conceivably be extended to include group by using negative numbers for grouping.
 
12:47 PM
if there is an easy enough way to convert Partition into Group I guess I can just make it be Group
maybe I could provide the conversion as a system function
so partition is just quad-Partition before group
 
If you have Group and a Partition left-argument, and want to partition, just do +\∪⍳⊢ on the left-argument.
 
@Adám not with IO zero though, right?
 
⎕IO isn't so important there, as the group numbers are just labels.
 
not really, 3 Group 1 is an array with two/three empty elements before one with a 1
 
Well, but it could be fixed to be 2 empties, even with ⎕IO←0. Not as if there is any existing code.
 
12:52 PM
I don't know, it seems kind of inconsistent
 
Note also that there's the oddity of telling Group how many groups you want in total. BQN allows an additional trailing element for this, but that seems very ad-hoc to me.
 
@Adám I'm not sure I understand, (+\∪⍳⊢) 1 1 2 2 1 is 1 2 4 6 7 instead of what I'd expect 1 1 2 2 3
 
Oops. Hang on.
Uh, that's actually wrong anyway. 1 1 2 2 1 should be 1 1 2 2 2 for Group.
You need +\2</0,⊢ to convert a Partition argument into a Group argument, assuming 0 means discard. (BQN shifts everything down by 1, iirc).
 
@Adám oh, Partition only checks increments, not just any change in the argument?
 
Exactly, hence how it works on a Boolean; it finds places where we go from 0 to 1.
 
1:05 PM
well it also finds places where we go from 1 to 0 because it splits there, no?
 
No, it doesn't split there, it just drops elements that correspond to 0s.
 
hmm, I see
so after the 0 it finds an increment and therefore creates a new partition
 
Yeah, otherwise 1 0 would create 2 segments, but it only creates 1.
 
2:07 PM
BQN–Dyalog dictionary has the translation (¬-˜⊢×·+`»⊸>)⊸⊔ for . They're so similar in one way but then the practical use of with a boolean left argument is totally different. Empty trailing groups are an issue with Partitioned Enclose but not Partition.
 
 
4 hours later…
6:13 PM
Hello, I am trying to get a handle on apl. I am working on implementing the KMP pattern searching algorithm and am very stuck. Currently I have taken the lower triangle of the equality cross product to find where characters from the pattern appear in the string:
f ← (⊢×∘.>⍨∘⍳∘≢)0⍪1↓∘.=⍨
I now want to somehow add along the diagonals, ensuring they start at the first column, to find the longest proper index. I am very confused, any help would be appreciated
 
It might be helpful with an example call and resut for f, and then the next value you want.
 
Sure, for a pattern equal to 'mamaam' my f is
0 0 0 0 0 0
0 0 0 0 0 0
1 0 0 0 0 0
0 1 0 0 0 0 0
0 1 0 1 0 0
1 0 1 0 0 0
and the value I want is
0 0 1 2 0 1
I realise this is pretty unclear, the array represents the longest proper prefix at each sub-set in the pattern
 
Can you explain how each of the six elements in the result is computed? You said diagonal sum, but I don't see it.
Are we talking ╱ or ╲ diagonals?
 
\ diagonals, but I agree it doesnt really work
I say diagonals as it feels close, but I now don't think that works
In python I would have the following solution:
def scanl(f, acc, arr):
if arr:
x, xt = arr[0], arr[1:]
return acc + scanl(f, f(acc, x), xt)
else:
return acc


init = [0]


def step(acc, x):
tmp = x[acc[-1]]
return [acc[-1] + 1] if tmp else [0]


m = [
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 1, 0, 1, 0, 0],
[1, 0, 1, 0, 0, 0],
]

print(scanl(step, init, m))
 
You could certainly translate that to APL.
 
6:36 PM
I will try it out, also will try make sense of my thoughts... Thanks!
 
6:48 PM
@user52971 A technique my father faught me was writing APL top-down. Start by writing your KMP function in terms of other functions, then, when APL complains with a VALUE ERROR that those are not defined, define each one that's complained about in terms of other things, etc. until it runs.
 
Nice that sounds like it could really help me in general. Hopefully I will have some nice updates to share
 

« first day (2661 days earlier)      last day (10 days later) »