I have a F # function:
let removeEven (listToGoUnder : _ list) = let rec listRec list x = match list with | [] -> [] | head::tail when (x%2 = 0) -> head :: listRec (tail) (x+1) | head::tail -> listRec (tail) (x+1) listRec listToGoUnder 0
It removes all elements with an even index in the list. It works if I give the list some imput, for example removeEven ['1';'2';'3']I get ['1';'3']which I should. But when I insert an empty list as a parameter, I get this error:
removeEven ['1';'2';'3']
['1';'3']
stdin (78.1): error FS0030: value limitation. The value "it" was supposed to have a common typeval it: '_a list Define' it 'as a simple data term, make it a function with explicit arguments, or if you do not intend to be general, add a type annotation.
stdin (78.1): error FS0030: value limitation. The value "it" was supposed to have a common type
val it: '_a list Define' it 'as a simple data term, make it a function with explicit arguments, or if you do not intend to be general, add a type annotation.
Help someone?
([]) ; . , []. :
[]
let results = removeEven ([]: int list)
, @kvb:
let results: int list = removeEven []
, , , removeOdd, 0, . , , , x :
removeOdd
0
x
let rec removeOdd = function | [] -> [] | [x] -> [x] | x::_::xs -> x::removeOdd xs