I am new to F # and trying to figure out some basics, but slowly stumble. In the code below, I am trying to create a list of random integers and then sort it.
let randomNumberList count =
let r = System.Random()
List.init count (fun _ -> r.Next(100))
let rec selectionSort l = function
| [] -> []
| l -> let min = List.min l in
let rest = List.filter (fun i -> i <> min) l in
let sortedList = selectionSort rest in
min :: sortedList
sortedList = selectionSort l
let unsortedList = randomNumberList 10
printfn "%A" unsortedList
printfn "%A" sortedList
So two things ... one error I get:
stdin(515,19): error FS0001: This expression was expected to have type
'a list
but here has type
'a list -> 'a list
The other is with a list of random numbers. It works, but I want the numbers created less than 100, instead of the massive values that I get now.
Thank you for your patience and help!
source
share