Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,33 +0,0 @@
-- Kernighans large earthquake problem
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
use Ada.Strings;
procedure Main is
Inpt_File : File_Type;
Space : Natural;
begin
Open (File => Inpt_File, Mode => In_File, Name => "data.txt");
while not End_Of_File (Inpt_File) loop
declare
Line : String :=
Trim (Source => Get_Line (File => Inpt_File), Side => Both);
begin
if Line'Length > 0 then
Space := Line'Last;
loop
exit when Line (Space) = ' ' or else Space = 0;
Space := Space - 1;
end loop;
if Space > 0 then
if Float'Value (Line (Space .. Line'Last)) > 6.0 then
Put_Line (Line);
end if;
end if;
end if;
end;
end loop;
Close (Inpt_File);
end Main;

View file

@ -4,7 +4,7 @@ data: {
5/18/1980 MountStHelens 7.6
}
define :earthquake [date place magnitude][]
define :earthquake [date place magnitude]
print first sort.descending.by:'magnitude map split.lines data =>
[to :earthquake split.words &]

View file

@ -1,85 +0,0 @@
*>
*> Kernighan large earthquake problem
*> Tectonics: cobc -xj kernighan-earth-quakes.cob
*> quakes.txt with the 3 sample lines
*> ./kernighan-earth-quakes
*>
>>SOURCE FORMAT IS FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. quakes.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
FUNCTION ALL INTRINSIC.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT quake-data
ASSIGN TO command-filename
ORGANIZATION IS LINE SEQUENTIAL
STATUS IS quake-fd-status.
DATA DIVISION.
FILE SECTION.
FD quake-data RECORD VARYING DEPENDING ON line-length.
01 data-line PICTURE IS X(32768).
WORKING-STORAGE SECTION.
01 quake-fd-status PICTURE IS XX.
88 ok VALUES ARE "00", "01", "02", "03", "04",
"05", "06", "07", "08", "09".
88 no-more VALUE IS "10".
88 io-error VALUE IS HIGH-VALUE.
01 line-length USAGE IS BINARY-LONG.
01 date-time PICTURE IS X(10).
01 quake PICTURE IS X(20).
01 magnitude PICTURE IS 99V99.
01 command-filename PICTURE IS X(80).
PROCEDURE DIVISION.
show-big-ones.
ACCEPT command-filename FROM COMMAND-LINE
IF command-filename IS EQUAL TO SPACES THEN
MOVE "data.txt" TO command-filename
END-IF
OPEN INPUT quake-data
PERFORM status-check
IF io-error THEN
DISPLAY TRIM(command-filename) " not found" UPON SYSERR
GOBACK
END-IF
READ quake-data
PERFORM status-check
PERFORM UNTIL no-more OR io-error
UNSTRING data-line DELIMITED BY ALL SPACES
INTO date-time quake magnitude
END-UNSTRING
IF magnitude IS GREATER THAN 6
DISPLAY date-time SPACE quake SPACE magnitude
END-IF
READ quake-data
PERFORM status-check
END-PERFORM
CLOSE quake-data
PERFORM status-check
GOBACK.
*> ****
status-check.
IF NOT ok AND NOT no-more THEN *> not normal status, bailing
DISPLAY "io error: " quake-fd-status UPON SYSERR
SET io-error TO TRUE
END-IF
EXIT PARAGRAPH.
END PROGRAM quakes.

View file

@ -1,33 +0,0 @@
*>
*> Tectonics: ./kerighan-earth-quakes <quakes.txt
IDENTIFICATION DIVISION.
PROGRAM-ID. quakes.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 data-line PICTURE IS X(32768).
88 no-more VALUE IS HIGH-VALUES.
01 date-time PICTURE IS X(10).
01 quake PICTURE IS X(20).
01 magnitude PICTURE IS 99V99.
PROCEDURE DIVISION.
show-big-ones.
ACCEPT data-line ON EXCEPTION SET no-more TO TRUE END-ACCEPT
PERFORM UNTIL no-more
UNSTRING data-line DELIMITED BY ALL SPACES
INTO date-time quake magnitude
END-UNSTRING
IF magnitude IS GREATER THAN 6
DISPLAY date-time SPACE quake SPACE magnitude
END-IF
ACCEPT data-line ON EXCEPTION SET no-more TO TRUE END-ACCEPT
END-PERFORM
GOBACK.
END PROGRAM quakes.

View file

@ -1,10 +0,0 @@
(with-temp-buffer
(insert-file-contents "data.txt")
(goto-char (point-min))
(while (not (eobp))
(let* ((line (buffer-substring (line-beginning-position)
(line-end-position)))
(magn (nth 2 (split-string line "\\s-+"))))
(when (> (string-to-number magn) 6.0)
(message line)))
(forward-line 1)))

View file

@ -1 +0,0 @@
perl -n -e '/(\S+)\s*$/ and $1 > 6 and print' data.txt

View file

@ -1,15 +1,13 @@
(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">filename</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"data.txt"</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">text</span> <span style="color: #0000FF;">=</span> <span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">platform</span><span style="color: #0000FF;">()=</span><span style="color: #004600;">JS</span> <span style="color: #008080;">or</span> <span style="color: #008080;">not</span> <span style="color: #7060A8;">file_exists</span><span style="color: #0000FF;">(</span><span style="color: #000000;">filename</span><span style="color: #0000FF;">)?</span><span style="color: #008000;">"""
8/27/1883 Krakatoa 8.8
5/18/1980 MountStHelens 7.6
3/13/2009 CostaRica 5.1"""</span> <span style="color: #0000FF;">:</span> <span style="color: #7060A8;">get_text</span><span style="color: #0000FF;">(</span><span style="color: #000000;">filename</span><span style="color: #0000FF;">))</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">lines</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">split_any</span><span style="color: #0000FF;">(</span><span style="color: #000000;">text</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\r\n"</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">lines</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">r</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">scanf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">lines</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">],</span><span style="color: #008000;">"%s %f"</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">if</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">r</span><span style="color: #0000FF;">)=</span><span style="color: #000000;">1</span> <span style="color: #008080;">and</span> <span style="color: #000000;">r</span><span style="color: #0000FF;">[</span><span style="color: #000000;">1</span><span style="color: #0000FF;">][</span><span style="color: #000000;">2</span><span style="color: #0000FF;">]></span><span style="color: #000000;">6</span> <span style="color: #008080;">then</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">lines</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--
with javascript_semantics
constant filename = "data.txt"
string text = iff(platform()=JS or not file_exists(filename)?"""
8/27/1883 Krakatoa 8.8
5/18/1980 MountStHelens 7.6
3/13/2009 CostaRica 5.1""" : get_text(filename))
sequence lines = split_any(text,"\r\n")
for i=1 to length(lines) do
sequence r = scanf(lines[i],"%s %f")
if length(r)=1 and r[1][2]>6 then
printf(1,"%s\n",{lines[i]})
end if
end for