noritsuguの日記

2009-04-07``Algorithms'' (32) Exercise 2.3

間違い探し

Prelude> 1:2:3

<interactive>:1:4:
    No instance for (Num [t])
      arising from the literal `3' at <interactive>:1:4
    Possible fix: add an instance declaration for (Num [t])
    In the second argument of `(:)', namely `3'
    In the second argument of `(:)', namely `2 : 3'
    In the expression: 1 : (2 : 3)
Prelude> 1:2:[3]
[1,2,3]
Prelude> [ [2,3]++[], [2,3]:[] ]

<interactive>:1:3:
    No instance for (Num [t])
      arising from the literal `2' at <interactive>:1:3
    Possible fix: add an instance declaration for (Num [t])
    In the expression: 2
    In the first argument of `(++)', namely `[2, 3]'
    In the expression: [2, 3] ++ []
Prelude> [ [[2,3]++[]], [2,3]:[] ]
[[[2,3]],[[2,3]]]
Prelude> "hello":"world"

<interactive>:1:8:
    Couldn't match expected type `[Char]' against inferred type `Char'
      Expected type: [[Char]]
      Inferred type: [Char]
    In the second argument of `(:)', namely `"world"'
    In the expression: "hello" : "world"
Prelude> "hello" ++ "world"
"helloworld"
トラックバック - http://haskell.g.hatena.ne.jp/noritsugu/20090407