Created
August 26, 2021 21:48
-
-
Save psteckler/5cf3ade082302f0605843814fc7d947d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
START_BLOCK="TBD" | |
END_BLOCK="TBD" | |
PK="TBD" | |
rm -f total.ml | |
cat <<EOF > total.ml | |
let run nums = | |
let total = List.fold_left Int64.add 0L nums in | |
Format.printf "%Ld@." total | |
let nums = [ | |
EOF | |
for file in `seq $START_BLOCK $END_BLOCK` | |
do (echo $file; cat blocks/$file | awk -f cummulative.awk | grep $PK | awk '{print '$file' " " $0}' | awk -f total.awk >> total.ml) | |
done | |
cat <<EOF >> total.ml | |
] | |
let take t_orig n = | |
if n <= 0 | |
then [] | |
else ( | |
let rec loop n t accum = | |
if n = 0 | |
then List.rev accum | |
else ( | |
match t with | |
| [] -> t_orig | |
| hd :: tl -> loop (n - 1) tl (hd :: accum)) | |
in | |
loop n t_orig []) | |
let _ = | |
let len = List.length nums in | |
let rec loop n = | |
if n > 0 then | |
let nums' = take nums n in | |
let block,_ = List.hd (List.rev nums') in | |
let actual_nums = List.map snd nums' in | |
Format.printf "AFTER BLOCK %d, TOTAL IS:@." block; | |
run actual_nums; | |
loop (n - 1) | |
in | |
loop len | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment