Skip to content

Instantly share code, notes, and snippets.

@Code-Hex
Created November 11, 2014 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Code-Hex/8aa231f5985617b921f2 to your computer and use it in GitHub Desktop.
Save Code-Hex/8aa231f5985617b921f2 to your computer and use it in GitHub Desktop.
二重mapの動きを知るためのコード
#!/usr/bin/perl
use strict;
use warnings;
my $num = 0;
map{$num += $_} map{$num += $_} 1..2;
print $num;
@Code-Hex
Copy link
Author

簡単に、1~2までを扱うことにしました。
それぞれ二つのmapを左map、右mapとします。

  1. 右mapに1を $_ に代入。(この時、$num = 1)
  2. 左mapに1を $_ に代入。(この時、$num = 2)
  3. 右mapに2を $_ に代入。(この時、$num = 4)
  4. 左mapに1を $_ に代入。(この時、$num = 5)
  5. 左mapに2を $_ に代入。(この時、$num = 7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment