brownplt / pyret-lang

The Pyret language.
Other
1.06k stars 106 forks source link

fold documentation appears to be incorrect #1703

Closed shriram closed 9 months ago

shriram commented 9 months ago

The signature says the first argument must be a function but the expansion shows it as the second argument.

image

This is for both fold and foldr.

Identified by Luna Wang.

sorawee commented 9 months ago

Already have a fix in https://github.com/brownplt/pyret-docs/pull/74 (though not yet merged)

EDITED: that's just one function though. Will fix another one.

shriram commented 9 months ago

Student also points out:

image

"Since the set appears to the left of the base b , shouldn't the function be in the form f :: (a, b -> b) instead?"

sorawee commented 9 months ago

The issues with foldl / foldr in the list documentation are now fixed.

@shriram: I don't understand what's wrong in your second comment. The method is documented correctly, agreeing with the implementation:

import sets as S

t1 = [S.tree-set: 1, 2, 3]

fun add(acc, elem) block:
  acc.add(elem + 100)
end

t1.fold(add, [S.tree-set: ]) # [tree-set: 101, 102, 103]

Perhaps the student meant that the argument ordering of set's .fold is not consistent with list's .foldl/r, which is true. But it's not fixable without breaking backward compatibility (then again, perhaps use context allows us to break backward compat?)

jpolitz commented 9 months ago

Thanks for PR on docs! Merged that and closing this.