#ocamlbook# #contents 標準ライブラリからの抜粋。これは説明したほうがいいんじゃね?というやつ。 - どのくらい詳しく解説するべきか…。長過ぎてもあれだし。 -- [[しもむら]] &new{2007-02-16 (金) 17:32:59}; #comment *Pervasives [#q59e1a2a] http://ocaml.jp/archive/ocaml-manual-3.06-ja/libref/Pervasives.html **例外 [#kf60eeec] - raise - failwith - Failture - Not_found **整数演算 [#i4fbe312] - abs - mod **浮動小数演算 [#d15ce771] - (**) - sqrt - exp - ceil - floor - int_of_float - infinity - neg_infinity - nan **文字列演算 [#z5e9dac3] - (^) ** 文字演算 [#r58f643d] - int_of_char - char_of_int ** 文字列演算 [#tcc1a4e8] - string_of_{bool,int,float} - {bool,int,float}_of_string ** リスト演算 [#bcb9bc97] - (@) ** 標準入出力 [#t44c4f9a] - stdin/stderr/stdout - print_string - print_char - print_int - print_float - read_line ** ファイル出力 [#p2b8d812] - open_out - output_string - close_out ** ファイル入力 [#t936411d] - open_in - input_string - close_in * Listモジュール [#j81613de] http://ocaml.jp/archive/ocaml-manual-3.06-ja/libref/List.html - length リストの長さを返します。 # List.length [1;2;3];; - : int = 3 # - hd リストの先頭要素を返します。 # List.hd [1;2;3];; - : int = 1 # 空リストに適用した場合には、例外を発生させます。 # List.hd [];; Exception: Failure "hd". # - tl リストの先頭要素を除いた残りを返します。hdと違い、返される値の型はリストになるので注意してください。 # List.tl [1;2;3];; - : int list = [2; 3] # こちらも、空リストに適用すると例外を発生させます。 # List.tl [];; Exception: Failure "tl". # - rev 与えられたリストの要素の順番を反転したものを返します。 # List.rev [1;2;3];; - : int list = [3; 2; 1] # - concat 与えられた"リストのリスト"を結合し、1つのリストにします。 # List.concat [[1;2];[3;4];[5;6]];; - : int list = [1; 2; 3; 4; 5; 6] # - map 引数に関数とリストを取って、リストの各要素に関数を適用する関数です。関数型言語らしい関数ですね。 - fold_left - mem - find - filter - sort * Arrayモジュール [#y340cc92] http://ocaml.jp/archive/ocaml-manual-3.06-ja/libref/Array.html - length - make - init - sub - to_list - of_list - map - mapi - fold_left - sort * Printfモジュール [#y6650be9] http://ocaml.jp/archive/ocaml-manual-3.06-ja/libref/Printf.html - printf - sprintf * Hasttblモジュール [#n5f238e7] http://ocaml.jp/archive/ocaml-manual-3.06-ja/libref/Hashtbl.html - create - clear - add - find - fold *Stream モジュール[#e563f928] http://ocaml.jp/archive/ocaml-manual-3.06-ja/libref/Stream.html [[streamの拡張構文:http://www.math.nagoya-u.ac.jp/~garrigue/papers/jssst-ocaml.html]] - of_list - of_string - of_channel - iter