【发布时间】:2019-05-28 20:56:04
【问题描述】:
我正在编写一个存储定义类型数组的类。我的代码语法有问题-我认为。我想在数组中获得一个定义的类型,但我的代码一直出错。
我已经创建了一个类,写下我需要的数组。我已经尝试过以这些方式编写它;
[|(Rook, Black, (Alive of (A, 1)))]
[|(Rook, Black, (Alive of A, 1))]
[|(Rook, Black, Alive of (A,1))]
[|(Rook, Black, Alive of A,1)]
[|(Rook, Black, (A,1))
但遗憾的是,它将我的数组显示为chess_piece * chess_colour * (chess_letter * int),否则会出现操作错误。
这是我定义的类型
type chess_letter = A | B | C | D | E | F | G | H
and chess_piece = King | Queen | Rook | Bishop | Knight | Pawn
and chess_colour = Black | White
and chess_position = Alive of chess_letter * int | Dead
数组应包含[|(chess_piece, chess_colour, chess_position)|]
【问题讨论】:
-
这不是 OOP,所以我删除了标签。您发布的代码中没有类或对象。