equalityとか。
相変わらず迷走中。
# (fun f tl -> let rec foo (l,r) xs = match xs with [] -> (List.rev r, List.rev l) | (x::xs) -> if (f x) then foo (l,x::r) xs else foo (x::l, r) xs in foo ([],[]) tl) (fun i -> i < 3) [1;2;3;4;5;1;2;3;4;6] ;; - : int list * int list = ([1; 2; 1; 2], [3; 4; 5; 3; 4; 6]) # List.partition (fun i -> i < 3) [1;2;3;4;5;1;2;3;4;6] ;; - : int list * int list = ([1; 2; 1; 2], [3; 4; 5; 3; 4; 6])
こんなんとか、
# let rec evenp x = match x with 0 -> true | _ -> oddp (x - 1) and oddp x = match x with 0 -> false | _ -> evenp (x -1) ;;
こんなので遊んでたり。andとか良くわかってなかった。
で、equalityでいろいろ
# let samep x y = Printf.printf "%b, %b\n" (x = y) (x == y) ;; val samep : 'a -> 'a -> unit = <fun>
とかこさえて
# let x = 1 in let y = 1 in samep x y;; true, true # let x = 1.0 in let y = 1.0 in samep x y;; true, false
へえ。floatは生成されちゃうのかな。
# let x = 'a' in let y = 'a' in samep x y;; true, true # let x = (1,1) in let y = (1,1) in samep x y;; true, false # let x = [1;1] in let y = [1;1] in samep x y;; true, false # let x = [|1;1|] in let y = [|1;1|] in samep x y;; true, false # let x = "one" in let y = "one" in samep x y;; true, false # let x = () in let y = () in samep x y;; true, true # let x = (+) in let y = (+) in samep x y;; Exception: Invalid_argument "equal: functional value".
まあそれ以外は予想通りか。
結論
実在は整数と文字と無。