On 04/04/2023 11:50, Will Mengarini wrote:
* cor...@free.fr <cor...@free.fr> [23-04/04=Tu 10:35 +0800]:
For instance, in ruby (irb) this is quite smooth:
irb(main):001:0> [1,2,3,4].map{|x|x+1}.reduce{|x,y|x+y}
=> 14
And in scala (shell):
scala> List(1,2,3,4).map{ _+1 }.reduce{_+_}
res1: Int = 14
In perl there is no interactive shell [...]
perl -le 'print eval $_ while <>'
In perl [...] the block statement seems strange:
$ perl -le '@x=(1,2,3,4); $sum+=$_ for( map {$_+1} @x );print $sum'
14
perl -le '@x=(1..4); print eval join "+", map $_+1, @x'
Too bad this is two days late, but Perl is an April 1 kind of language.
I heard in perl never 'eval' a string. :)