pyret-lang
pyret-lang copied to clipboard
Better aliases for foldl and foldr?
In the lists module, there are .foldl and .foldr methods, but no foldl and foldr functions. These should be defined.
And they probably should be called fold-left and fold-right, to avoid unnecessarily making things sound cryptic. That goes for the method names, too.
It might be better to call them fold-forward and fold-backward, given how hard it is to remember which is which by the name.
Or perhaps "fold" and "fold-backward", then, just to make the one most likely to be used shorter?
Stevie
On Oct 20, 2014, at 4:35 PM, Joe Politz [email protected] wrote:
And they probably should be called fold-left and fold-right, to avoid unnecessarily making things sound cryptic. That goes for the method names, too.
It might be better to call them fold-forward and fold-backward, given how hard it is to remember which is which by the name.
— Reply to this email directly or view it on GitHub https://github.com/brownplt/pyret-lang/issues/353#issuecomment-59835240.
Nice, I like that.
Is there any better word than fold to use here? That's the last remaining piece of jargon in the name.
Some languages use "reduce", but I don't like that. "combine"? "mix"? I'm not sure if I can come up with a verb that's clearly descriptive of the process yet not jargony here, though.
Stevie
On Oct 20, 2014, at 4:48 PM, Joe Politz [email protected] wrote:
Nice, I like that.
Is there any better word than fold to use here? That's the last remaining piece of jargon in the name.
— Reply to this email directly or view it on GitHub https://github.com/brownplt/pyret-lang/issues/353#issuecomment-59837234.
I don't think fold is too jargon-y, since it's not a made-up word and I always have the mental picture of folding up a list as a long strip of paper, one item at a time...
Plus, I think list.fold is indeed currently defined :-)
Yeah, agreed. I think of it as folding in baking (which is why combine and mix came to mind for me if we wanted a replacement).
On Oct 20, 2014, at 5:11 PM, Ben Lerner [email protected] wrote:
I don't think fold is too jargon-y, since it's not a made-up word and I always have the mental picture of folding up a list as a long strip of paper, one item at a time...
Plus, I think list.fold is indeed currently defined :-)
Reply to this email directly or view it on GitHub.
Agreed. Also, people are going to expect to find fold. So Stevie's
suggestion is best. May be good to alias foldl and foldr due to
convention.
On Mon, Oct 20, 2014 at 5:28 PM, Stevie Strickland <[email protected]
wrote:
Yeah, agreed. I think of it as folding in baking (which is why combine and mix came to mind for me if we wanted a replacement).
On Oct 20, 2014, at 5:11 PM, Ben Lerner [email protected] wrote:
I don't think fold is too jargon-y, since it's not a made-up word and I always have the mental picture of folding up a list as a long strip of paper, one item at a time...
Plus, I think list.fold is indeed currently defined :-)
Reply to this email directly or view it on GitHub.— Reply to this email directly or view it on GitHub https://github.com/brownplt/pyret-lang/issues/353#issuecomment-59842736.
After lecturing on fold today, I realized that fold-backward might be kinda confusing, since (assuming we mean fold-right by fold-backward) it is the one that keeps the list in order if you use it with link. As in, I'm about to give out a programming assignment where the answer to "which one keeps the list in the same order" will be fold-backward. But fold-left demonstrably goes forward if you just print the elements in the combining function and watch the effects. Mmph.
Are left/right actually better, since one operation's "backward" is another's "forward"?
Is this issue staying open because of the unresolved "better alias name" question? If so, can we change the title? And if not, can we close?
I'm changing the title, since the original title is pretty confusing.