Take the 2-minute tour ×

i am getting this error in the interactive window on http://www.tryfsharp.org. It works fine in visual studio and im not sure how to tackle it.Any help would be appreciated

let randomNumberGenerator count =
    let rnd = System.Random()
    List.init count (fun numList -> rnd.Next(0, 100))

let rec sortFunction = function
| [] -> []
| l -> let minNum = List.min l in
       let rest = List.filter (fun i -> i <> minNum) l in
       let sortedList = sortFunction rest in
       minNum :: sortedList

let List = randomNumberGenerator 10
let sortList = sortFunction List
printfn "Randomly Generated numbers in a NON-SORTED LIST\n"
printfn "%A" List
printfn "\nSORTED LIST \n"
printfn "%A \n" sortList

error FS0039: The field, constructor or member 'init' is not defined

Aprreciate your help

share|improve this question
Can you paste the code for which you are getting the error ? –  Ankur Jun 2 '11 at 5:11
Code added in the first post. –  Amp231 Jun 2 '11 at 17:44

1 Answer 1

You should be getting the error only when you run the code for the second time and it shoul behave the same in the TryF# console as well as locally in Visual Studio.

The problem is that you're declaring a value named List:

let List = randomNumberGenerator 10

which hides the standard module List. After you declare the value List.init tries to access a member of this List value instead of accessing a function in the standard List module.

There is a good reason for naming conventions, such as using lowercase for local variable names :-)

share|improve this answer
Thanks...it works now :) –  Amp231 Jun 2 '11 at 17:58
Please mark this as the accepted answer (green check mark) then. –  Brian Jun 3 '11 at 17:05

Your Answer


