diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-06 15:40:52 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-06 15:40:52 +0200 |
| commit | e73ad00f44479e3065ccf12d07ca3ae22ca1f3f0 (patch) | |
| tree | 628c4957a9e53815d1ccf49f87a1002ccc059ac6 /examples/aoc22_1.milch | |
| parent | 21ee11d3df3000a77d5b36d3c7e0a18d9a07d599 (diff) | |
Remove ! from end of builtin top-level functions
Diffstat (limited to 'examples/aoc22_1.milch')
| -rw-r--r-- | examples/aoc22_1.milch | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/examples/aoc22_1.milch b/examples/aoc22_1.milch index 4170661..7a4520a 100644 --- a/examples/aoc22_1.milch +++ b/examples/aoc22_1.milch @@ -1,23 +1,23 @@ -(import! "stdlib/common.milch") +(import "stdlib/common.milch") ;; utils ; convert ["a" "b" "c"] into "abc" -(let! str-from-vec (\[vec] +(let str-from-vec (\[vec] (foldr concat "" vec))) ;; solution -(let! sample-path "examples/aoc22_1.txt") -(let! sample-input (read-file! sample-path)) +(let sample-path "examples/aoc22_1.txt") +(let sample-input (read-file! sample-path)) (print-fmt! "Read {0} characters from \"{1}\"\n" [ (len sample-input) sample-path]) -(let! sample-vec (to-vec sample-input)) +(let sample-vec (to-vec sample-input)) -(let! result1 (pipe sample-vec [ +(let result1 (pipe sample-vec [ (split-by "\n") (map str-from-vec) (split-by "") @@ -27,3 +27,16 @@ ])) (print-fmt! "Result 1: {0}\n" [result1]) + +(let result2 (pipe sample-vec [ + (split-by "\n") + (map str-from-vec) + (split-by "") + (map (map parse-int)) + (map (foldr + 0)) + (sort-by (* -1)) + (take 3) + (foldr + 0) +])) + +(print-fmt! "Result 2: {0}\n" [result2]) |
