简体   繁体   English

如何在ocaml中删除int * int列表的标题

[英]How to delete head of a list of int*int in ocaml

Im trying to remove the head of list of type (int*int) using List.filter but i get an error. 我试图使用List.filter删除类型(int * int)的列表的头,但出现错误。 This is what i am trying to do: 这就是我想要做的:

List.filter (fun (i,j) -> List.tl <> List.hd) lst

Do you really want to do that with List.filter ? 您真的要使用List.filter做到这List.filter吗? It's not its purpose. 这不是它的目的。 If you are absolutely certain the head has no duplicate in the list, you could do 如果您完全确定列表中没有重复的头,则可以这样做

List.filter (fun u -> u <> List.hd lst) lst

But note List.tl lst will do it better. 但是请注意List.tl lst会做得更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM