Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Directions in an array.
Synopsis
- type LOC n = (n, n)
- type VEC n = (n, n)
- vector_add :: Num n => VEC n -> VEC n -> VEC n
- vector_sub :: Num n => VEC n -> VEC n -> VEC n
- vector_sum :: Num n => [VEC n] -> VEC n
- apply_vec :: Num n => LOC n -> VEC n -> LOC n
- segment_vec :: Integral n => VEC n -> [VEC n]
- derive_vec :: Num n => LOC n -> LOC n -> VEC n
- unfold_path :: Num n => LOC n -> [VEC n] -> [LOC n]
- type DIRECTION_S = String
- is_direction :: String -> Bool
- type DIRECTION_C = Char
- direction_char_to_vector_tbl :: Num n => [(DIRECTION_C, VEC n)]
- direction_char_to_vector :: Num n => DIRECTION_C -> VEC n
- direction_to_vector :: Num n => [DIRECTION_C] -> VEC n
- vector_to_direction_char :: (Eq n, Num n) => VEC n -> DIRECTION_C
- dir_seq_to_cell_seq :: (String, [String]) -> [String]
LOC / VEC
segment_vec :: Integral n => VEC n -> [VEC n] Source #
Segment VEC
into a sequence of unit steps.
let r = [[(0,0)],[(0,1)],[(0,1),(-1,0)],[(0,1),(0,1),(0,1),(-1,0),(-1,0)]] in map segment_vec [(0,0),(0,1),(-1,1),(-2,3)] == r
DIRECTION (non-diagonal)
type DIRECTION_S = String Source #
is_direction :: String -> Bool Source #
Directions are D=down, L=left, R=right, U=up.
type DIRECTION_C = Char Source #
direction_char_to_vector_tbl :: Num n => [(DIRECTION_C, VEC n)] Source #
Reads either S|D W|L E|R N|U, reverse lookup gives SWEN. A period indicates (0,0). S=south, W=west, E=east, N=north.
direction_char_to_vector :: Num n => DIRECTION_C -> VEC n Source #
direction_to_vector :: Num n => [DIRECTION_C] -> VEC n Source #
vector_to_direction_char :: (Eq n, Num n) => VEC n -> DIRECTION_C Source #