bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Absolute limits of rank 2 bool matrix size in GNU APL?


From: Russtopia
Subject: Re: Absolute limits of rank 2 bool matrix size in GNU APL?
Date: Fri, 31 Dec 2021 18:53:35 -0800

Hi Hans-Peter, 

do you mind if I post a cleaned-up version of your solution to the word count/frequency problem on Rosettacode.org ? http://rosettacode.org/wiki/Word_frequency

That was the original motivation for my attempting a solution, as there was no APL example yet posted there.

Regards,
-Russ

---

Hi Rus,

looks like the outer product is a not needed - you have the unique words and along the line you got the word count too.

you take the sorted word vector
swv ←'aa' 'bb' 'bb' 'cc' 'cc' 'ff' 'gg'

then you create a partition vector from it
pv←+\1,~2≡/swv
pv

1 2 2 3 3 4 5

partition for wc
     pv⊂pv
1  2 2  3 3  4  5

Then the wc is
wc←∊⍴¨ pv ⊂ pv
     wc

and the unique words are
     uw←1⊃¨ pv ⊂ swv
     uw
aa bb cc ff gg


finally the listing of occurrences
     ⊃uw,¨wc
aa 1
bb 2
cc 2
ff 1
gg 1


Best Regards
Hans-Peter
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]