From e91f633a53aa1d285708edfc50c1ffb92a49fcc9 Mon Sep 17 00:00:00 2001 From: Jinhyuk Jeon Date: Fri, 31 Aug 2018 16:05:58 +0900 Subject: [PATCH] adding somee resules --- hw1.ml | 19 +++++++++++++++++++ test.ml | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 hw1.ml diff --git a/hw1.ml b/hw1.ml new file mode 100644 index 0000000..d979684 --- /dev/null +++ b/hw1.ml @@ -0,0 +1,19 @@ + +let rec merge (l1,l2) = + match (l1,l2) with + | ([], _) -> l2 + | (_, []) -> l1 + | (h1::t1, h2::t2) -> h1::h2::merge(t1,t2) + + + +let rec printer msg = + match msg with + | [] -> () + | h::t -> + print_int h; + printer t + +let greeter = merge([1;2;3],[4;5;6]) + +let _ = printer greeter diff --git a/test.ml b/test.ml index 2f194f7..2fc16e4 100644 --- a/test.ml +++ b/test.ml @@ -1,3 +1,33 @@ + +let _ = print_int 13 + +let rec merge2 l1 l2 = + match (l1,l2) with + | ([], _) -> l2 + | (_, []) -> l1 + | (h1::t1, h2::t2) -> + if h1

l2 + | (_,[]) -> l1 + | (h1::t1, h2::t2) -> + h1::h2::merge(t1,t2) + +let rec listprint msg = + match msg with + | [] -> () + | h::t -> + print_int h; + my_print t + +let lister = merge ([1;2;3],[4;5;6]); + +let _ = listpint lister + +(* let greeting = 'H'::'e'::'l'::'l'::'o'::[] let rec my_print msg = @@ -9,14 +39,14 @@ let rec my_print msg = let _ = my_print greeting +*) - -(*type pair = Mk_pair of char*char +(*(*type pair = Mk_pair of char*char let greeting = "Hello World" let my_print deco msg = - match deco with + match deco with *) | Mk_pair (prolog, epilog) -> print_char prolog; print_string msg;