projects
/
onyx.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
18ad476
)
fixed: critical bug in `iter.fold` producing wrong values
author
Brendan Hansen
<brendan.f.hansen@gmail.com>
Wed, 6 Dec 2023 16:29:30 +0000
(10:29 -0600)
committer
Brendan Hansen
<brendan.f.hansen@gmail.com>
Wed, 6 Dec 2023 16:29:30 +0000
(10:29 -0600)
core/container/iter.onyx
patch
|
blob
|
history
diff --git
a/core/container/iter.onyx
b/core/container/iter.onyx
index ca4f8252861fa6b36196ebb2c6f70da78a1e1241..e37de430441b309d67d6ad7af4da5a3643377587 100644
(file)
--- a/
core/container/iter.onyx
+++ b/
core/container/iter.onyx
@@
-749,11
+749,13
@@
fold :: macro (it: $T/Iterable, init: $R, combine: $S) =>
#overload
fold :: (it: Iterator($T), initial_value: $R, combine: (T, R) -> R) -> R {
+ result := initial_value;
+
for value: it {
-
initial_value = combine(value, initial_value
);
+
result = combine(value, result
);
}
- return
initial_value
;
+ return
result
;
}