"
ニュー速民はどの言語が一番美しいと思う?

Python
print map(lambda x: x*2, filter(lambda x: x>2 and x<5, [1,2,3,4,5]))

Ruby
puts [1,2,3,4,5].select{|i| i > 2 and i < 5}.map{|i| i*2}

Haskell
print [x*2| x <-[1,2,3,4,5], x > 2, x < 5]

231: 名無しさん@涙目です。(氷川神社) 2012/01/03(火) 20:01:53.17 ID:UPNLrdrw0
»220
Ruby以外何やってるかわからない///

282: 名無しさん@涙目です。(氷川神社) 2012/01/03(火) 20:20:48.00 ID:uyyum2Wh0
»220
pythonなら
[x*2 for x in [1,2,3,4,5] if x > 2 and x < 5]
だろ
一番読みやすいわ

305: 名無しさん@涙目です。(近江神宮) 2012/01/03(火) 20:29:36.68 ID:NPDXpAGf0
»220
new{}{ 1,2,3,4,5 }
 .Where(x => 2 < x && x < 5)
 .Select(x => x*2);

ここまではできるけどC#だとさっと書き出せないですな

588: 名無しさん@涙目です。(新疆ウイグル自治区) 2012/01/03(火) 22:52:21.79 ID:LT5+kC4X0
»220
PowerShellで書くとこんな感じ
1..5 -gt 2 -lt 5 | % { $_ * 2 }
"

01/14/2012
12:04 PM
Permalink 12 notes
Comments

  1. ds9-garak reblogged this from alio2
  2. poochin reblogged this from alio2
  3. cuon reblogged this from s-hsmt
  4. alio2 reblogged this from s-hsmt
  5. yuibb reblogged this from s-hsmt
  6. s-hsmt reblogged this from text-man
  7. mhiki reblogged this from raitu
  8. text-man reblogged this from raitu
  9. raitu posted this
blog comments powered by Disqus