Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我被困在 Poly/ML 中的函数式编程练习中:
执行 ''a list -> int 类型的函数,以便将 ''a 元素列表作为参数。该函数必须返回列表中元素的数量,而不计算重复项。
我真的不知道如何解决它。
在此先感谢您的帮助!
稍微重新表述一下:“列表中唯一元素的数量”,即“删除重复项后列表的长度”。
您可能已经知道如何找到列表的长度,所以这是解决的一个子问题。
现在您已经留下了“从列表中删除重复元素”,我将其留作练习。 (“从列表中删除一个特定值”可能是一个很好的步骤。)