2017-07-24 68 views
1

运行稔0.17.0或更新版本,在Windows 8.1测试与VCC 2017年工具链运行,如下的编译过程中产生的错误:从算法模块“排序”给出模棱两可的/无类型错误

import algorithm 

var toSort = @["b", "c", "d"] 
for sorted in toSort.sort(system.cmp): 
    echo sorted 

我Nim非常新,但是我的sort电话会遇到什么问题?

回答

1

sort程序不返回任何东西。它就地修改了列表。你想用sorted代替:

import algorithm 

var toSort = @["b", "c", "d"] 
for sorted in toSort.sorted(system.cmp): 
    echo sorted 
+0

李自成的代码示例从[排序文件(https://nim-lang.org/docs/algorithm.html#sort,openArray [T],PROC(T ,T))现在让我明白这一点。谢谢! – bsinky