F # Iterating: Le type «unité» ne correspond pas au type «char»
Question
J'ai cette fonction
let items = ['a'; 'a'; 'a'; 'a'; 'b'; 'b'; 'a'; 'a'; 'c'; 'd'; 'd'; 'e'; 'e';]
open System
let rng = new Random()
let randomSelect list toget = let randomList k len = List.init k (fun _ -> rng.Next(1,len))
let getK l k = List.nth l k
let primeGet = getK list
List.length list
|> randomList toget
|> List.iter (fun i -> primeGet i)
let res23 = randomSelect items 3
Mais pour une raison quelconque, la fonction s'attend à une liste d'unités, pas générique
Le type «unité» ne correspond pas au type «char»
Pourquoi cela arrive-t-il ?
Pas de solution correcte
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow