#ocamlbook#
標準ライブラリからの抜粋。これは説明したほうがいいんじゃね?というやつ。
http://ocaml.jp/archive/ocaml-manual-3.06-ja/libref/Pervasives.html
http://ocaml.jp/archive/ocaml-manual-3.06-ja/libref/List.html
リストの長さを返します。
# List.length [1;2;3];; - : int = 3 #
リストの先頭要素を返します。
# List.hd [1;2;3];; - : int = 1 #
空リストに適用した場合には、例外を発生させます。
# List.hd [];; Exception: Failure "hd". #
リストの先頭要素を除いた残りを返します。hdと違い、返される値の型はリストになるので注意してください。
# List.tl [1;2;3];; - : int list = [2; 3] #
こちらも、空リストに適用すると例外を発生させます。
# List.tl [];; Exception: Failure "tl". #
与えられたリストの要素の順番を反転したものを返します。
# List.rev [1;2;3];; - : int list = [3; 2; 1] #
与えられた"リストのリスト"を結合し、1つのリストにします。
# List.concat [[1;2];[3;4];[5;6]];; - : int list = [1; 2; 3; 4; 5; 6] #
引数に関数とリストを取って、リストの各要素に関数を適用する関数です。関数型言語らしい関数ですね。
http://ocaml.jp/archive/ocaml-manual-3.06-ja/libref/Array.html
http://ocaml.jp/archive/ocaml-manual-3.06-ja/libref/Printf.html
http://ocaml.jp/archive/ocaml-manual-3.06-ja/libref/Hashtbl.html
http://ocaml.jp/archive/ocaml-manual-3.06-ja/libref/Stream.html