Re:A little thing to love about Perl 6 and COBOL
by agumonkey on Wednesday February 04, 2015 @08:05PM
(#9001155)
Because these are two basic building blocks of 'computation', I'd say first order. It's map and reduce in disguise (or the other way around, doesn't matter).
- [record] -> [derived from record] :: map
- Begin and End blocks are accumulator/stateful logic :: reduce
sed is also a little twisted version of awk, per line mapping, with pattern spaces for accumulations.It's first order, because it can't reuse itself on smaller pieces of data, namely recursion (grammars, trees, etc)
Re:A little thing to love about Perl 6 and COBOL
by cbd1984 on Wednesday February 04, 2015 @11:36PM
(#9001760)
That's awk. That is literally the control flow style of awk, which Larry Wall copied into Perl very directly and entirely deliberately.
I find it very interesting that RPG uses it, and I wonder if it's convergent evolution (relative to awk and RPG) or if one is copying the other.
The control flow is:
- Run a set of zero or more statements once at the beginning
- Run a set of statements once per input record
- Run a set of zero or more statements once at the end
I was always struck by the similarity to:
BEGIN { ... }
while (<>) {
}END{ ... }