Clojure 创建高阶优先函数
Clojure creating higher order first function
; Now create a function that takes a function (which produces a sequence)
; as an argument. Your function should invoke that function and return and
; return the first element from the returned sequence.
(is (higher-order-first-function? __))
伙计们,这实际上是我作业的一部分。我有 1000 行代码要做。这只是我不知道该怎么做的一部分。谁能帮我解决这个问题?我尝试了所有可能的方法但是。我无法通过测试。
所以评论中的步骤已经很清楚了:
- 编写一个需要一个参数的函数(使用 defn、fn 或 #())
- 该参数应该是一个函数,所以检查一下 (fn?)
- 调用那个函数
- Return返回序列中的第一个元素(first)
; Now create a function that takes a function (which produces a sequence)
; as an argument. Your function should invoke that function and return and
; return the first element from the returned sequence.
(is (higher-order-first-function? __))
伙计们,这实际上是我作业的一部分。我有 1000 行代码要做。这只是我不知道该怎么做的一部分。谁能帮我解决这个问题?我尝试了所有可能的方法但是。我无法通过测试。
所以评论中的步骤已经很清楚了:
- 编写一个需要一个参数的函数(使用 defn、fn 或 #())
- 该参数应该是一个函数,所以检查一下 (fn?)
- 调用那个函数
- Return返回序列中的第一个元素(first)