【问题标题】:tuple inside another tuple in OCAMLOCAML 中另一个元组中的元组
【发布时间】:2017-05-15 14:30:09
【问题描述】:

我的问题在标题中,这是一个例子:

(int * string * string * int * (string * string * int) list)

我可以这样做吗?我试过了,但没有用,我想知道是否有办法做到这一点......

【问题讨论】:

    标签: tuples ocaml


    【解决方案1】:

    简单地说:

    type t = int * string * string * int * (string * string * int) list;;
    

    【讨论】:

      【解决方案2】:

      Pierre G. 解释了如何定义类型。如果您想知道如何创建这样的元组,您可以在不先定义类型的情况下进行。只需使用您想要的数据构建一个元组。例如:

      (1, "two", "three", 4, [("five", "six", 7); ("eight", "nine", 10)]);;
      

      返回

      int * string * string * int * (string * string * int) list =
      (1, "two", "three", 4, [("five", "six", 7); ("eight", "nine", 10)])
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-01-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-10
        • 1970-01-01
        相关资源
        最近更新 更多