Kernighans large earthquake problem: Difference between revisions
Kernighans large earthquake problem (view source)
Revision as of 10:27, 1 February 2021
, 3 years agoAdd APL
Not a robot (talk | contribs) (Add Bash) |
Not a robot (talk | contribs) (Add APL) |
||
Line 387:
8/27/1883 Krakatoa 8.8
5/18/1980 MountStHelens 7.6</pre>
=={{header|APL}}==
{{works with|Dyalog APL}}
This runs from the APL prompt, taking the filename as the right argument
and the magnitude as an optional left argument (defaulting to 6).
<lang APL>quakes←{
⍺←6
nl←⎕UCS 13 10
file←80 ¯1⎕MAP ⍵
lines←((~file∊nl)⊆file)~¨⊂nl
keep←⍺{0::0 ⋄ ⍺ < ⍎3⊃(~⍵∊4↑⎕TC)⊆⍵}¨lines
↑keep/lines
}</lang>
{{out}}
<pre> quakes'data.txt'
8/27/1883 Krakatoa 8.8
5/18/1980 MountStHelens 7.6
5 quakes'data.txt'
8/27/1883 Krakatoa 8.8
5/18/1980 MountStHelens 7.6
3/13/2009 CostaRica 5.1
8 quakes'data.txt'
8/27/1883 Krakatoa 8.8
</pre>
=={{header|AWK}}==
|