Drkcore

20 09 2007 perl HOP Tweet

perlの grep $_, @_;

HOP6.5でなんだコレは?と。($_,@_)なんてありなのかと思ったがどうも違った。

sub test {
  my ($h, @s) = grep $_, @_;
  print "h:\t$h\n";
  print "s:\t";
  print join ",",@s,"\n";
}

test(3,undef,1,4,5);

実行結果

h:      3
s:      1,4,5,

配列の中からundefを除く、($_,@_)っていう配列ではなくて grep {$_} @_みたいな感じのgrep tipsだった。

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021