Alternate for making such a thing work in perl : `for(10…0)`

后端 未结 3 1300
青春惊慌失措
青春惊慌失措 2021-01-18 02:20

This doesn\'t work in perl : for(10...0) It essentially doesn\'t loop even once, because it checks that 10>0 initially.

Any alternate s

3条回答
  •  孤城傲影
    2021-01-18 03:20

    for (map -$_,-10..0) { ... }
    for (map 10-$_,0..10) { ... }
    

    If any part of the range is negative, then the first one is shorter than using reverse.

提交回复
热议问题