module Aoc import Prelude -- `by` is the first argument for use in `map` nums' : String → String → List Int nums' by s = map stringToInt $ filter (_/=_ "") $ split (trim s) by nums : String → List Int nums s = map stringToInt $ filter (_/=_ "") $ split (trim s) " " indexOf? : ∀ a. {{Eq a}} → a → List a → Maybe Nat indexOf? {a} z xs = go Z z xs where go : Nat → a → List a → Maybe Nat go ix z Nil = Nothing go ix z (x :: xs) = if z == x then Just ix else go (S ix) z xs -- TODO move to Aoc library Point : U Point = Int × Int instance Add Point where (a,b) + (c,d) = (a + c, b + d) instance Sub Point where (a,b) - (c,d) = (a - c, b - d) -- instance Ord Point where -- (a,b) < (c,d) = a < c || a == c && b < d -- instance Eq Point where -- (a,b) == (c,d) = a == c && b == d -- Doesn't play well with scheme and was removed from prelude, a couple of days depend on it for BigInt pfunc jsCompare uses (EQ LT GT) : ∀ a. a → a → Ordering := `(_, a, b) => a == b ? Prelude_EQ : a < b ? Prelude_LT : Prelude_GT` pfunc jsEq uses (True False) : ∀ a. a → a → Bool := `(_, a, b) => a == b ? Prelude_True : Prelude_False`