我想我在某处读到了一些关于List.toString的东西,但是对于l = [1,2,3]; print (List.toString (l) ),我得到了Error: unbound variable or constructor: toString in path List.tostring,而print l给了我
Error: operator and operand don't agree [tycon mismatch]
operator domain: string
operand: int list
in expression:
print a那么,如何将列表转换为字符串并打印出来呢?这不是很难,但在搜索如何打印一个简单的列表时,我没有找到答案。在本例中,我有一个In列表。
我发现了这个
fun f (x: int list) = (PolyML.print x; ());Here。
但它给了我Error: unbound structure: PolyML in path PolyML.print
发布于 2016-04-23 04:01:35
以下是可以在SML /NJ中使用的SML版本:
fun printList xs = print(String.concatWith ", " (map Int.toString xs));该函数接受一个int列表,将其转换为字符串表示的列表,然后使用",“连接字符串,最后打印结果。
https://stackoverflow.com/questions/36799572
复制相似问题