gpt4 book ai didi

Clojure 序列长度

转载 作者:行者123 更新时间:2023-12-03 00:58:38 25 4
gpt4 key购买 nike

我可以发誓我之前有alength工作,但我不太知道我现在做错了什么:

user=> (alength '(1 2 3))
IllegalArgumentException No matching method found: alength clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:79)
user=> (alength [1 2 3])
IllegalArgumentException No matching method found: alength clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:79)
user=> (doc alength)
-------------------------
clojure.core/alength
([array])
Returns the length of the Java array. Works on arrays of all
types.
nil

我应该怎么做才能获取 Clojure 中列表/数组的长度?

最佳答案

尝试使用count :

(count '(1 2 3))
=> 3
(count [1 2 3])
=> 3

关于Clojure 序列长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8632495/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com