私は現在これを試みています。
let L = [2; 4; 6; 8]
let fourth listx = List.nth(listx 3);;
fourth L;;
しかし、私は'a -> 'a
(リストからリストへ)したくないint -> 'a
これを修正するにはどうすればよいですか?
私は現在これを試みています。
let L = [2; 4; 6; 8]
let fourth listx = List.nth(listx 3);;
fourth L;;
しかし、私は'a -> 'a
(リストからリストへ)したくないint -> 'a
これを修正するにはどうすればよいですか?
You want something like
let fourth listx = List.nth listx 3
This gives a signature of 'a list -> 'a
which is I think what you want. The key difference is the absence of brackets which don't do what you are expecting in this case
let fourth x = (fun x -> [x]) (List.nth x 3)
val fourth : x:'a list -> 'a list