Intersecting number wheels: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: Tidied, applied Ormolu.) |
m (→{{header|Haskell}}: Tidied, pruned out one import, preferring a guard to bool.) |
||
Line 893: | Line 893: | ||
terminating at the first digit found, and printing a map-accumulation of that recursion over a list of given length but arbitrary content. |
terminating at the first digit found, and printing a map-accumulation of that recursion over a list of given length but arbitrary content. |
||
<lang haskell>import Data. |
<lang haskell>import Data.Char (isDigit) |
||
import Data.Char (isDigit) |
|||
import Data.List (mapAccumL) |
import Data.List (mapAccumL) |
||
import qualified Data.Map.Strict as M |
import qualified Data.Map.Strict as M |
||
Line 907: | Line 906: | ||
where |
where |
||
click wheels name = |
click wheels name = |
||
let |
let go m c |
||
| isDigit c = (m, c) |
|||
| otherwise = click m c |
|||
in ( go . flip (M.insert name . leftRotate) wheels |
|||
<*> head |
|||
) |
|||
(M. |
(fromMaybe ['?'] (M.lookup name wheels)) |
||
v |
|||
leftRotate :: [a] -> [a] |
leftRotate :: [a] -> [a] |