Letter frequency: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: made p2js compatible (via making it count words of 17 chars or more from unix_dict()))
(→‎{{header|APL}}: Add file I/O.)
Line 367: Line 367:


=={{header|APL}}==
=={{header|APL}}==
<lang apl>freq←{(⍪∪⍵),+/(∪⍵)∘.⍷⍵}
<lang apl>
freq←{(⍪∪⍵),+/(∪⍵)∘.⍷⍵}


freq 0 1 2 3 2 3 4 3 4 4 4
freq 0 1 2 3 2 3 4 3 4 4 4
Line 382: Line 381:
l 2
l 2
o 2
o 2
n 1
n 1</lang>

</lang>
The above solution doesn't do the "open a text file" part of the task. File I/O is implementation-dependent, but here's how to do it in Dyalog:

{{works with|Dyalog APL}}
<lang apl>text ← ⊃⎕nget 'filename'</lang>

... after which the above <tt>freq</tt> function can be applied to <tt>text</tt>.


=={{header|AppleScript}}==
=={{header|AppleScript}}==