Unique characters: Difference between revisions
Content added Content deleted
m (→{{header|J}}) |
m (→{{header|J}}: grammar) |
||
Line 866: | Line 866: | ||
The simple approach here is to merge the argument strings and find characters which occur exactly once in that intermediate result: |
The simple approach here is to merge the argument strings and find characters which occur exactly once in that intermediate result: |
||
<lang J>uniques=: ~.#~1=#/.~</lang> |
<lang J>uniques=: ~.#~1=#/.~</lang> |
||
In other words, <code>~.</code> finds the distinct characters, <code>#/.~</code> finds the corresponding counts of those characters, so <code>1=#/.~</code> is true for the characters which occur exactly once, and <code>#~</code> filters the distinct characters based on |
In other words, <code>~.</code> finds the distinct characters, <code>#/.~</code> finds the corresponding counts of those characters, so <code>1=#/.~</code> is true for the characters which occur exactly once, and <code>#~</code> filters the distinct characters based on those truth values. |
||
{{out}} |
{{out}} |
||
<pre> uniques;'133252abcdeeffd';'a6789798st';'yxcdfgxcyz' |
<pre> uniques;'133252abcdeeffd';'a6789798st';'yxcdfgxcyz' |