aiken-lang / stdlib

The Aiken Standard Library

Home Page:https://aiken-lang.github.io/stdlib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong example in docs

ariady-putra opened this issue · comments

List.reduce example-arguments are flipped:
https://aiken-lang.github.io/stdlib/aiken/list.html#reduce

reduce(self: List<a>, zero: b, with: fn(b, a) -> b) -> b

Reduce a list from left to right using the accumulator as left operand. Said differently, this is foldl with callback arguments swapped.

list.reduce([#[1], #[2], #[3]], bytearray.concat, #[0]) == #[0, 1, 2, 3]
list.reduce([True, False, True], fn(b, a) { or([b, a]) }, False) == True

It should be:

list.reduce([#[1], #[2], #[3]], #[0], bytearray.concat) == #[0, 1, 2, 3]
list.reduce([True, False, True], False, fn(b, a) { or([b, a]) }) == True

pub fn reduce(self: List<a>, zero: b, with: fn(b, a) -> b) -> b {

commented

Ah yes, we had switched the arguments in the definitions last release, thanks for pointing this out