How to generate an array with random values, without using a loop?

后端 未结 24 2193
逝去的感伤
逝去的感伤 2020-12-13 19:23

How can I generate an array in Perl with 100 random values, without using a loop?

I have to avoid all kind of loops, like \"for\", foreach\", while. This is my exerc

24条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 20:03

    my @rand = map { rand } ( 1..100 );
    

    But a map is just a loop with fancy window-dressing.

    If you need to do something 100 times, you're going to need to use some kind of iterative structure.

提交回复
热议问题