Esthetic numbers: Difference between revisions
Content added Content deleted
(→{{header|Haskell}}: added more efficient solution) |
m (→{{header|Haskell}}: fixed typos) |
||
Line 2,724: | Line 2,724: | ||
differences >>= fromBase b <$> scanl (+) firstDigit |
differences >>= fromBase b <$> scanl (+) firstDigit |
||
-- Much more efficient iterative solution (translation from Python) |
-- Much more efficient iterative solution (translation from Python). |
||
-- Uses simple list as an ersatz queue. |
-- Uses simple list as an ersatz queue. |
||
esthetics b = tail $ fst <$> iterate step ( |
esthetics b = tail $ fst <$> iterate step (undefined, q) |
||
where |
where |
||
q = [(d, d) | d <- [1..b-1]] |
q = [(d, d) | d <- [1..b-1]] |