Hacker News new | ask | show | jobs
by elcaro 1038 days ago

  >  "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)

2 comments

I've just found the key exchanges that arrived at "produce" by using the IRC log search[1] and then, er, scanning backwards to where the exchange began[2]:

> 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

I recall Larry saying the key visual aspect is the `\` (I don't recall him mentioning the `/`) because `[\` visually echoes the typical shape of results:

    .say for [\**] 2,3,4

    4                          #           4
    81                         #      3 ** 4
    2417851639229258349412352  # 2 ** 3 ** 4