bug-apl
[Top][All Lists]
Advanced

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

[Bug-apl] The Dyalog ⌸ operator


From: Elias Mårtenson
Subject: [Bug-apl] The Dyalog ⌸ operator
Date: Wed, 27 Apr 2016 11:02:28 +0800

I was reading about the Dyalog "key" operator ⌸. It's certainly a useful function, and something that should probably be added to GNU APL, in my opinion.

As always when thinking about useful additions to GNU APL, I wanted to try to do some things that ⌸ can do, without having access to it.

So, I wanted to simply take a string of characters, and create a list of each character and the number of occurrences of each character in that string. My solution works, but feels clumsy:

       { ⊃{(↑⍵) (↑⍴⍵)}¨(⎕UCS v) ⊂ v←⍵[⍋⍵] } "abcfoobat"
┏→━━━━┓
↓'a' 2┃
┃'b' 2┃
┃'c' 1┃
┃'f' 1┃
┃'o' 2┃
┃'t' 1┃
┗━━━━━┛

Can anyone improve this? In particular, can it be improved to the point of convincing me that ⌸ is not needed?

Regards,
Elias

reply via email to

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