【发布时间】:2023-09-16 20:01:01
【问题描述】:
SML 长度函数:
fun length(L) =
if (L=nil) then 0
else 1+length(tl(L));
例如:
length [1,2,3] = 3;
length [ [5], [4], [3], [2,1] ] = 4;
根据代码,如果我也想统计列表中的元素,怎么改?
例如:
length [ [5], [4], [3], [2,1] ] = 5;
【问题讨论】: