hubFS: THE place for F#

. . . are you on The Hub?
Welcome to hubFS: THE place for F# Sign in | Join | Help
in Search

Article Releases

F#の入門

F#はパソコン言語の一種で、関数型言語(かんすうがたげんご)と言われています。それは抽象化(ちゅうしょうか)的に関数を使うので、オブジェクト指向(しこう)言語のジャバとかC++などとは違います。始めて目にした時、F#の関数はジャバのメソッドとにとても似ていると思うだろう。

 

F#                                                        ジャバ

 

let square x = x * x          int square(int x) {
                                  return x * x;
                              }

 

しかしF#は上位関数型言語なので、関数は値にも使うことができます。たとえば、「map」は上位関数で、受け取り関数をリストの要素(ようそ)と呼びます:

 

> map square [1; 2; 3; 4];;
val it : int list = [1; 4; 9; 16]

 

ここでは関数の「square」が引数されて使われます。「map」はF#で使うとても書きやすいです:

 

let rec map f xs =
    match xs with
    | [] -> []
    | x::xs’ -> (f x) :: map f xs’

 

ジャバで書くことはどんな上位関数でも難しいので、簡単な「map」でさえ(みじか)く、(わか)りやすく、そして容易(ようい)に書くことができません。一般的にはF#プログラムの長さはジャバの長さの十パーセントぐらいしかありません。

 

F#の生まれについて

 

2002年に、ケンブリッジにあるマイクロソフトの研究所で、情報工学者(じょうほうこうがくしゃ)のドン・サイム博士が、F#言語とコンパイラーを初めて作りました。最近ではF#が段々と人々に広まり一般的になりました。ヨーロッパでも、アメリカでも、アジアでも多くの科学者、学生、インベストメントアナリストもF#でプログラミングをしています。

Published Wednesday, April 26, 2006 11:22 PM by dcooney

Comments

 

Don Syme's WebLog on F# and Other Research Projects said:



I’m very glad to announce a new F# community initiative called “The Hub”, hosted at http://cs.hubfs.net,...
April 27, 2006 6:45 PM
 

jameshuddleston said:

The code is nice, but I can't read the text.
May 9, 2006 7:15 AM
Anonymous comments are disabled

About dcooney

Dominic Cooney is a Software Design Engineer at Microsoft Corporation in sunny Redmond, Washington. He's also working on programming language support for web services in the Programming Languages and Systems Group at the Queensland University of Technology, where he's a PhD candidate. In his ample spare time he's learning Japanese and writing a vanity blog at http://www.dcooney.com.

This Blog

Post Calendar

<April 2006>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

Syndication

Powered by Community Server, by Telligent Systems