by elcaro · 3y ago · 0 comments
> "Produce" is a term I've never seen used this way before, and I assume it is unique to Raku.
More commonly referred to in the functional languages as a `scan`, but yes, it seems that `produce` might be unique to Raku. I've not seen `accumulate` outside of Python, but there's a lot of langs so who knows.code_report (Conor Hoekstra) has discussed the difference names of `scan` on a couple occasions, eg: https://twitter.com/code_report/status/1246494250537291776
Connor has declared a fondness of APL's where fold and scan show a clear visual relation: `/` & `\`. I suspect Raku was shooting for something similar with it's choices:
[f] list # or list.reduce(f)
[\f] list # or list.produce(f)
> TimToady: is it okay to rename the 'reduce' builtin to 'fold' and add one for 'scan'? My understanding is that 'reduce' is the general term for them both.
[1] https://irclogs.raku.org/search.html?query=produce+reduce&ty...
[2] https://irclogs.raku.org/perl6/2006-05-15.html#17:10-0001
.say for [\**] 2,3,4
4 # 4
81 # 3 ** 4
2417851639229258349412352 # 2 ** 3 ** 4