��������䤷�����ä��Τȡ����������ؿ���̾�����դ������ä��ΤȤ�1 entry�䤯���Ȥˤ��ޤ�����

�������� - �����ȥ�
��������ܤ���2��ˤ��줾��黻��ܤ�����������������Ĥޤꡢ
f (+) [1,2,3,4,5] = [3,5,7,9]
�Τ褦�� f ���ߤ�����

̾��

������������������Τˤ⤳�δؿ��ϻȤ���ΤǤ��������ΰ���Ū�˻Ȥ���ؿ��˻Ȥ�̾���Ȥ��ƤϤ��ޤ�˶ɽ�Ū���Ȥ����櫓�� mapBetween �Ȥ��Ƥߤޤ������Ȥ��ɤ����Ϥ��ʤ�¿�����Ǥ����Ƹ����ɸ����������Ƥ��ʤ��Τ�����ä��Ի׵Ĥʤۤɡ�

JavaScript�ˤ�����

Array.prototype.map����¿�˻Ȥ��ʤ����������ȤäƤߤޤ�����

Array.prototype.mapBetween = function(callback, thisArg) {
    return this.slice(0, -1).map(function(v, i) {
        return callback.call(thisArg, v, this[i]);
    }, this.slice(1));
};

Perl�ˤ�����

map BLOCK LIST��BLOCK�θƤӽФ��Ǥϥ����å����Ѥޤʤ����Ĥޤ�@_�����ΤޤޤǤ������˵����դ��Ȱʲ��Τ褦�˽񤱤ޤ���

use 5.012;

sub mapBetween(&@) {
    map { $_[0]->( $_[$_], $_[ $_ + 1 ] ) } 1 .. @_ - 2;
}

say '# ', join ",", mapBetween { $_[1] - $_[0] } ();
say '# ', join ",", mapBetween { $_[1] - $_[0] } (0);
say '# ', join ",", mapBetween { $_[1] - $_[0] } (0, 1);
say '# ', join ",", mapBetween { $_[1] - $_[0] } (0, 1, 4);
say '# ', join ",", mapBetween { $_[1] - $_[0] } (0, 1, 4, 9);

������CORE::sort()��List::Utils()�ʤɤǸ����롢�����������$a��$b��Ȥ���ˡ�ˤ��б������褦�Ȥ���Ⱦ������פ�ɬ�פȤʤ�ޤ�������ʤȤ����Ǥ��礦����

use 5.012;

sub mapBetween(&@) {
    my $pkg = caller();
    no strict 'refs';
    map {
        local ( ${ $pkg . '::a' }, ${ $pkg . '::b' } ) =
          ( $_[$_], $_[ $_ + 1 ] );
        $_[0]->( $a, $b )
    } 1 .. @_ - 2;
}

{
    our ( $a, $b ) = ( 'a', 'b' );
    say '# ', join ",", mapBetween { $b - $a } ();
    say '# ', join ",", mapBetween { $b - $a } (0);
    say '# ', join ",", mapBetween { $b - $a } ( 0, 1 );
    say '# ', join ",", mapBetween { $b - $a } ( 0, 1, 4 );
    say '# ', join ",", mapBetween { $b - $a } ( 0, 1, 4, 9 );
    say $a, $b;
}
{
    package NotMain;
    our ( $a, $b ) = ( 'A', 'B' );
    say '# ', join ",", main::mapBetween { $b - $a } ();
    say '# ', join ",", main::mapBetween { $b - $a } (0);
    say '# ', join ",", main::mapBetween { $b - $a } ( 0, 1 );
    say '# ', join ",", main::mapBetween { $b - $a } ( 0, 1, 4 );
    say '# ', join ",", main::mapBetween { $b - $a } ( 0, 1, 4, 9 );
    say $a, $b;
}

Enjoy!

Dan the Mapper in between

' ).text(); } var query = {s:text}; if (lang) query['l'] = lang; var url = 'http://api.dan.co.jp/lleval.cgi'; var proto = 'json'; if ($.browser.msie || $.browser.opera){ url += '?c=?'; proto += 'p'; } /* falls back to JSONP */ $.get(url, query, function(json){ $(dstNode).html(json2table(json)).hide().show('slow'); }, proto); }; })(jQuery);