関数型プログラミング言語Haskell Part20at TECH
関数型プログラミング言語Haskell Part20 - 暇つぶし2ch7:デフォルトの名無しさん
12/10/17 11:34:17.99
■ C
for( const char *s="12345"; *s; ++s ) if( '2'<*s&&*s<'5' ) printf( "%d", (*s-'0')*2 );
■ JavaScript
console.log([1,2,3,4,5].filter(function (i){ return i > 2 && i < 5 ; }).map(function(i){ return 2 * i; }));
■ 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}
■ C#
new{}{ 1,2,3,4,5 }.Where(x => 2 < x && x < 5).Select(x => x*2);
■ Common Lisp
(print (loop for x in '(1 2 3 4 5) if (< 2 x 5) collect (* x 2)))
■ Haskell
print [x*2| x <-[1,2,3,4,5], x > 2, x < 5]
■ Perl
print map {$_*$_} grep {2<$_ and $_<5} 1..5;
■ Mathematica
{1,2,3,4,5}~Select~(2<#<5&) 2
■ MATLAB
x=[1 2 3 4 5]; x(2<x&x<5).*2
■ Scheme
(print (list-ec (: x 1 6) (if (< 2 x)) (if (< x 5)) (* x 2)))
■ Clojure
(for [x (range 1 6) :when (and (> x 2) (< x 5))] (* 2 x))




次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch