Skip to content

Instantly share code, notes, and snippets.

@sugitach
Created November 13, 2014 10:37
Show Gist options
  • Save sugitach/de9960abe1bd0b189177 to your computer and use it in GitHub Desktop.
Save sugitach/de9960abe1bd0b189177 to your computer and use it in GitHub Desktop.
(* 目的:ふたつのリストを受け取って長さが同じかどうかを返す *)
(* equal_length : a' list -> b' list -> bool *)
let rec equal_length lst1 lst2 =
match lst1 with
[] -> (match lst2 with [] -> true | _::_ -> false)
| f1::r1 -> (match lst2 with [] -> false | f2::r2 -> equal_length r1 r2)
(* テスト *)
let test1 = equal_length [] [] = true
let test2 = equal_length [1; 2; 3] ["a";"b";"c"] = true
let test3 = equal_length [] [1;2;3;4] = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment