Hi Russ,

that's a good idea. Thank you.

Regards,
Hans-Peter

Am 01.01.22 um 03:53 schrieb Russtopia:
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