
Barbara Shirtcliff
Also, note that "lexOrder s@[_] = [s]" is nicer than "lexOrder s | length s == 1 = [s]".
I agree that that initial version was a little clumsy, but your suggestion doesn't really seem to work:
lexOrder :: [Char] -> [[Char]] lexOrder s@[_] = s lexOrder s = concat $ map (\n -> h n) [0..((length z) - 1)] where z = sort $ nub s h :: Int -> [String] h n = map (z!!n :) $ lexOrder $ filter (\c -> lexI c z /= n) z
Euler.hs:8:18: Couldn't match expected type `[Char]' with actual type `Char' Expected type: [[Char]] Actual type: [Char] In the expression: s In an equation for `lexOrder': lexOrder s@[_] = s
It actually works, you have forgotten square brackets: "lexOrder s@[_] = [s] --not s!".