On Sat, Mar 27, 2021 at 4:47 AM Eirik Berg Hanssen < Eirik-Berg.Hanssen@allverden.no> wrote: > On Sat, Mar 27, 2021 at 4:35 AM Darren Duncan <darren@darrenduncan.net> > wrote: > >> So which of these is considered better code? >> >> Functional design: >> >> my $result1 = op2(op1($input1)); >> >> my $result2 = [map { op2(op1($_)) } @{$input2}]; >> >> Procedural design: >> >> my $result1 = $input1; >> op1($result1); >> op2($result1); >> >> my $result2 = []; >> foreach $elem (@{$input2}) >> { >> op1($elem); >> op2($elem); >> push(@{$result2}, $elem); >> } >> > > I don't think anyone is arguing for the latter. Try this instead: > > Chomp-like design: > > op2(op1(my $result1 = $input1)); > > op2(op1(my @result2 = @input2)); > Err, except if it is truly chomp-like, it won't chain ⦠oops? op1(my $result1 = $input1); op2 $result1; op1(my @result2 = @input2); op2 @result2; Hmm ⦠depending on the input record separator, I could see myself doing this: chomp(my @result = <>); trim @result; ⦠and chomp being what it is, I cannot see it being written any easier with a functional trim ⦠But I'm missing the point, aren't I? It's not how it chains or not with the existing chomp that's in question, but rather how it chains with user defined functions or procedures? Eirik EirikThread Previous | Thread Next