# meeting3 log languages

オープンバイオ対決 というテーマで考えていたもののうち、「関数/メソッド比較表」の部分の作成を行ってみました。これの元のアイデアは、高林さんのブログ「配列操作の比較表: Ruby, Python, JavaScript, Perl, C++」です。

## 文字列

スペースがダメダメですがあとで表に直します。orz

```文字列           Ruby                            Python                          Perl
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----
リテラル         str = "abc"                     str = "abc"                     \$str = "abc";
-------------------------------------------------------------------------------−−−−−-----
str = %Q[a"bc]                  ???                             \$str = qq/a"bc/;
str = %q[ab'c]                  ???                             \$str = q/ab'c/;
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----
つなぐ           x = "abc"; y = "de"             x = "abc"; y = "de"             \$x = "abc"; \$y = "de";
str = x + y                     str = x + y                     \$str = \$x . \$y;
------------------------------------------------------------------------------------------−−−−−−−−−−-----
ふやす           str = x * 10                    ???                             \$str = \$x x 10;
------------------------------------------------------------------------------------------−−−−−−−−−−-----

-------------------------------------------------------------------------------−−−−−-----

-------------------------------------------------------------------------------−−−−−-----
rna = dna.dup                   ???                             \$rna = \$dna;
str[0..-2]                      str[:-1] (or str[0:-1])         substr(\$str, 0, -2);
-----------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------−−−−−−−−−−-----
slice           str[m, n]                       ???                             substr(\$str, \$m, \$n);
------------------------------------------------------------------------------------------−−−−−−−−−−-----
reverse         rev = str.reverse               ???                             \$rev = reverse(\$str);
------------------------------------------------------------------------------------------−−−−−−−−−−-----
complement      rev.tr("atgc, "tacg")                                           \$rev =~ tr/atgc/tacg/;
------------------------------------------------------------------------------------------−−−−−−−−−−-----

-----------------------------------------------------------------------------------------
rna = dna.dup                   ???                             \$rna = \$dna;
rna.gsub!("t", "u")                                             \$rna =~ s/t/u/g;
-------------------------------------------------------------------------------−−−−−-----
str.sub(">", "> ")                                              ???
-------------------------------------------------------------------------------−−−−−-----
str.sub!(/^>/, "> ")                                            \$str =~ s/^>/> /;
-------------------------------------------------------------------------------−−−−−-----
str.sub!(/^>?S+/) {|x| x.downcase}
------------------------------------------------------------------------------------------−−−−−−−−−−-----
マッチ           str[/re/]
-----------------------------------------------------------------------------------------
str =~ /re/                                                     \$str =~ /re/;
-----------------------------------------------------------------------------------------
s = str[/re/]                                                   \$s = /(re)/ for \$str;
(\$s) = \$str =~ /(re)/;
------------------------------------------------------------------------------------------−−−−−−−−−−-----
upcase          str.upcase                      ???                             uc(\$str);
------------------------------------------------------------------------------------------−−−−−−−−−−-----
downcase        str.downcase                    ???                             lc(\$str);
------------------------------------------------------------------------------------------−−−−−−−−−−-----```

## ハッシュ

```Hash            Ruby                                    Python                          Perl
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----
リテラル         h = {}                          h = {}                          %h = ();
-------------------------------------------------------------------------------−−−−−-----
h = {"a" => 1, "b" => 2}        h = {a:1, b:2}                  %h = (a => 1, b => 2);
-------------------------------------------------------------------------------−−−−−-----
@h{"a", "b"} = (1, 2);
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----
オブジェクト      a = [1, 2, 3]                   a = [1, 2, 3]                   @a = (1, 2, 3);
b = [4, 5]                      b = [4, 5]                      @b = (4, 5);
h[a1] = b2                      ???                             \$h{?@a} = ?@a2;
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----
キーだけ         h.keys                          h.keys()                        keys %h
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----

sum += v                        sum += v                        ???
end                                                             }
-------------------------------------------------------------------------------−−−−−-----
h.inject(0) {|sum, k, v| sum+= v}
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----
ソート           h.sort.each do |k, v|           ???                             for (sort keys %h) {
puts "#{k} -> #{v}"                                             ???
end                                                             }
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----

h.sort{|x,y| y[1] <=> x[1]}
−−−−−−−−−−−−−−−−-−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−-----```
##### Clone this wiki locally
You can’t perform that action at this time.
Press h to open a hovercard with more details.