【问题标题】:OCaml Stack of tuplesOCaml 元组堆栈
【发布时间】:2012-09-10 02:48:17
【问题描述】:

我正在尝试使用以下代码在 OCaml 中创建一组元组

let (k : (string*string) Stack.t) = Stack.create ;;

但是这样做时我在编译时遇到错误

Error: This expression has type unit -> 'a Stack.t
   but an expression was expected of type (string * string) Stack.t

我对 OCaml 很陌生。有人能指出我哪里出错了吗?

【问题讨论】:

    标签: stack ocaml tuples


    【解决方案1】:

    Stack.create 是一个函数,它接受值 ()(类型为 unit)并返回一个堆栈。

    所以你应该这样做:

    let (k : (string*string) Stack.t) = Stack.create ();;
    

    如果你写Stack.create,你只说功能,而不是结果。

    【讨论】:

      猜你喜欢
      • 2011-11-24
      • 2017-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-12
      • 1970-01-01
      • 2010-10-24
      相关资源
      最近更新 更多