
I don't see anything wrong with this function, which just subtracts 1 from the first element of an Int list (if there is a first element). Michael My function: dropFirst :: [Int] -> [Int] dropFirst [] = [] dropFirst (x:xs) = (x-1) : xs My output:
:l dropfirst [1 of 1] Compiling Main ( dropfirst.hs, interpreted ) Ok, modules loaded: Main. *Main> dropFirst [3 4 5 6]
<interactive>:1:11: No instance for (Num (t -> t1 -> t2 -> Int)) arising from the literal `3' at <interactive>:1:11-17 Possible fix: add an instance declaration for (Num (t -> t1 -> t2 -> Int)) In the expression: 3 4 5 6 In the first argument of `dropFirst', namely `[3 4 5 6]' In the expression: dropFirst [3 4 5 6] *Main>

在 2010年 1月 17日 星期日 11:02:59,michael rice 寫道:
I don't see anything wrong with this function, which just subtracts 1 from the first element of an Int list (if there is a first element).
Michael
My function:
dropFirst :: [Int] -> [Int] dropFirst [] = [] dropFirst (x:xs) = (x-1) : xs
My output:
:l dropfirst
[1 of 1] Compiling Main ( dropfirst.hs, interpreted ) Ok, modules loaded: Main. *Main> dropFirst [3 4 5 6]
Use dropFirst [3,4,5,6], I think.
<interactive>:1:11: No instance for (Num (t -> t1 -> t2 -> Int)) arising from the literal `3' at <interactive>:1:11-17 Possible fix: add an instance declaration for (Num (t -> t1 -> t2 -> Int)) In the expression: 3 4 5 6 In the first argument of `dropFirst', namely `[3 4 5 6]' In the expression: dropFirst [3 4 5 6] *Main>

Dumb! I've been hacking Lisp and just slipped over to Haskell to check on something.
Thanks,
Michael
--- On Sat, 1/16/10, VoidPrayer
I don't see anything wrong with this function, which just subtracts 1 from the first element of an Int list (if there is a first element).
Michael
My function:
dropFirst :: [Int] -> [Int] dropFirst [] = [] dropFirst (x:xs) = (x-1) : xs
My output:
:l dropfirst
[1 of 1] Compiling Main ( dropfirst.hs, interpreted ) Ok, modules loaded: Main. *Main> dropFirst [3 4 5 6]
Use dropFirst [3,4,5,6], I think.
<interactive>:1:11: No instance for (Num (t -> t1 -> t2 -> Int)) arising from the literal `3' at <interactive>:1:11-17 Possible fix: add an instance declaration for (Num (t -> t1 -> t2 -> Int)) In the expression: 3 4 5 6 In the first argument of `dropFirst', namely `[3 4 5 6]' In the expression: dropFirst [3 4 5 6] *Main>
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

*Main> dropFirst [3 4 5 6] List members are separated by commas.
Space in Haskell denotes function application. Hence the error message: Hence t
No instance for (Num (t -> t1 -> t2 -> Int)) arising from the literal `3' at <interactive>:1:11-17 Possible fix: add an instance declaration for (Num (t -> t1 -> t2 -> Int))
participants (3)
-
michael rice
-
Rahul Kapoor
-
VoidPrayer