Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,5 @@
python -c '
with open("data.txt") as f:
for ln in f:
if float(ln.strip().split()[2]) > 6:
print(ln.strip())'

View file

@ -0,0 +1,38 @@
from os.path import expanduser
from functools import (reduce)
from itertools import (chain)
# largeQuakes :: Int -> [String] -> [(String, String, String)]
def largeQuakes(n):
def quake(threshold):
def go(x):
ws = x.split()
return [tuple(ws)] if threshold < float(ws[2]) else []
return lambda x: go(x)
return concatMap(quake(n))
# main :: IO ()
def main():
print (
largeQuakes(6)(
open(expanduser('~/data.txt')).read().splitlines()
)
)
# GENERIC ABSTRACTION -------------------------------------
# concatMap :: (a -> [b]) -> [a] -> [b]
def concatMap(f):
return lambda xs: list(
chain.from_iterable(
map(f, xs)
)
)
# MAIN ---
if __name__ == '__main__':
main()