Skip to content

Commit

Permalink
adding somee resules
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinhyuk Jeon committed Aug 31, 2018
1 parent ef1cec4 commit e91f633
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
19 changes: 19 additions & 0 deletions hw1.ml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 33 additions & 3 deletions test.ml
Original file line number Diff line number Diff line change
@@ -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<h2 then h1::merge t1 l2
else h2::merge l1 t2

let rec merge (l1,l2) =
match(l1,l2) with
| ([],_) -> 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 =
Expand All @@ -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;
Expand Down

0 comments on commit e91f633

Please sign in to comment.