module Go.Util exposing (..) import Go.Types exposing (..) -- Search for a value in a list of key-value pairs. lookup : a -> List (a, b) -> Maybe b lookup val list = Maybe.map Tuple.second (List.head (List.filter (\(a, _) -> a == val) list)) -- Computes all possible indices on a board of size n. allIndices : Int -> List Index allIndices n = let vals = List.range 0 (n - 1) pairs = \xs i -> List.map (\x -> (i, x)) xs in List.concatMap (pairs vals) vals zip : List a -> List b -> List (a, b) zip xs ys = case (xs, ys) of (x::xb, y::yb) -> (x, y) :: (zip xb yb) _ -> []