sml - 为什么List结构中有些函数需要 "List"前缀而有些则不需要?

标签 sml smlnj

(我使用的是 SML/NJ)

列表结构http://sml-family.org/Basis/list.html包括 @、hd、tl、null、concat 等

其中一些无需前缀即可使用:@、hd、tl、[]、concat。 但其他的,例如exists 和nth 需要List 前缀。见下文:

Standard ML of New Jersey v110.79 [built: Tue Aug  8 23:21:20 2017]
- op @;
val it = fn : 'a list * 'a list -> 'a list
- concat;
val it = fn : string list -> string
- nth;
stdIn:3.1-3.4 Error: unbound variable or constructor: nth
- exists;
stdIn:1.2-2.1 Error: unbound variable or constructor: exists
- List.nth;
[autoloading]
[library $SMLNJ-BASIS/basis.cm is stable]
[library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable]
[autoloading done]
val it = fn : 'a list * int -> 'a
- List.exists;
val it = fn : ('a -> bool) -> 'a list -> bool
为什么?我试图在“标准机器学习的定义(1997)”中找到答案 但我找不到任何与此相关的内容。

最佳答案

某些名称可以不经过限定,因为它们也绑定(bind)在 SML Basis 库的顶级环境中,包括您列出的名称。请参阅here获取完整列表。

关于sml - 为什么List结构中有些函数需要 "List"前缀而有些则不需要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52395716/

相关文章:

list - 创建用于测试不同类型函数的测试框架

unit-testing - 具有多种结构的 SML 签名

functional-programming - ML 函数柯里化(Currying)

sml - 如何在sml中打印变量?

recursion - 使用差异列表快速序列化 BST

programming-languages - 为什么 SML 和 OCaml 被视为 ML 的方言?机器学习的定义是什么?

sml - 数据类型 Nt = int | ML 中的字符串

functional-programming - fn : 'a -> ' b 类型的 ml 函数

list - 如何在SML中找到列表中最大的数字

list - 记录列表上的 SML 功能