0

私は現在これを試みています。

let L = [2; 4; 6; 8]

let fourth listx  = List.nth(listx 3);;

fourth L;;

しかし、私は'a -> 'a(リストからリストへ)したくないint -> 'a

これを修正するにはどうすればよいですか?

4

2 に答える 2

4

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

于 2013-09-17T01:58:20.633 に答える
0
let fourth x = (fun x -> [x]) (List.nth x 3)
val fourth : x:'a list -> 'a list
于 2013-09-17T02:12:51.493 に答える