我有一条称为Move的记录,其定义如下:
type Move = {
X : int
Y : int
By: CellState }
我创建了一个移动列表(Move list list
)来存储一些数据。我想从此列表中删除重复的条目。在我的示例中,每个子列表具有相同的内容,但顺序不同。打印时如下所示:
[[{X = 5;
Y = 1;
By = R;}; {X = 5;
Y = 0;
By = B;}; {X = 4;
Y = 0;
By = B;}]; [{X = 5;
Y = 0;
By = B;}; {X = 4;
Y = 0;
By = B;}; {X = 5;
Y = 1;
By = R;}];
[{X = 4;
Y = 0;
By = B;}; {X = 5;
Y = 1;
By = R;}; {X = 5;
Y = 0;
By = B;}]]
此列表包含3个列表,每个列表具有3条记录。每个列表具有相同的记录,但是顺序不同。我想知道是否有办法从主列表中删除重复的子列表
答案 0 :(得分:2)
如果您订购子列表,那么List.distinct
可以解决问题:
yourList
|> List.map List.sort
|> List.distinct