用zig的for作为表达式,实现reduce的功能? #135
-
大佬们,如下写法实现reduce的功能是否是合理的?
看到https://course.ziglang.cc/basic/process_control/loop#%E4%BD%9C%E4%B8%BA%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%BF%E7%94%A8 |
Beta Was this translation helpful? Give feedback.
Answered by
jiacai2050
Jul 17, 2024
Replies: 1 comment 3 replies
-
累加要放到 for 里面,https://ziglang.org/documentation/master/#toc-for |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
原来你是这个意思。
但觉得不是个好设计,你觉得栗子还比较简单,如果是个string,那你怎么处理?没有地方传 allocator 了,缺少一个 context。