Jump to content

Kernighans large earthquake problem: Difference between revisions

Add APL
(Add Bash)
(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}}==
2,114

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.