正如评论者所说,您的解决方案已经可以了。另一种选择是使用comp,可能像这样:
user> (defn n-times [n f]
(apply comp (repeat n f)))
#'user/n-times
user> ((n-times 10 inc) 1)
;;=> 11
Run Code Online (Sandbox Code Playgroud)
我仍然不能说它在任何方面是否比你的更好。也许更实用[ish]
| 归档时间: |
|
| 查看次数: |
1655 次 |
| 最近记录: |