walk 必须 return 与输入相同的类型?

walk must return same type as input?

我不清楚提供给 walkouter 函数应该如何工作。

此处引用的文档中的示例: https://docs.hylang.org/en/stable/contrib/walk.html

建议 outer 函数可以是 first,这将 return 通过 inner.

映射生成的集合的第一个元素

然而,当我尝试在 outer 中汇总结果时(例如 sumfirst),我收到如下错误 - 抱怨 int 不是可迭代 - 查看源代码我怀疑这是因为宏定义中的 (type form):

((type form) (outer (HyExpression (map inner form))))

任何人都可以确认并建议是否有办法让 outer return 与输入 form 不同的类型?即 (walk inc sum [1 2 3 4 5]) 是否可以像我期望的那样提供列表 [2 3 4 5 6] 的总和?

=> (walk inc identity [1 2 3 4 5])
[2, 3, 4, 5, 6]
=> (walk inc accumulate [1 2 3 4 5])
[2, 5, 9, 14, 20]
=> (walk inc sum [1 2 3 4 5])
Traceback (most recent call last):
  File "stdin-75eb4a20707c49e8c921e986e7d6164d36b7e4b2", line 1, in <module>
    (walk inc sum [1 2 3 4 5])
  File "/home/phil/.local/lib/python3.6/site-packages/hy/contrib/walk.hy", line 22, in walk
    ((type form) (outer (HyExpression (map inner form))))]
TypeError: 'int' object is not iterable
=> (walk inc first [1 2 3 4 5])
Traceback (most recent call last):
  File "stdin-710dcc990bf071fe1a9a4c5501831c41867f1879", line 1, in <module>
    (walk inc first [1 2 3 4 5])
  File "/home/phil/.local/lib/python3.6/site-packages/hy/contrib/walk.hy", line 22, in walk
    ((type form) (outer (HyExpression (map inner form))))]
TypeError: 'int' object is not iterable
=> 

It's a bug. 改为 (sum (map inc [1 2 3 4 5]))