Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* 2.3 list_upcase *)
- (* 1.1 char_upcase *)
- let rec char_upcase x =
- if x < 'a' || x > 'z'
- then
- print_char x
- else
- print_char (Char.chr((Char.code x)-(Char.code 'a' - Char.code 'A')))
- ;;
- (* 1.2 string_iter *)
- let string_iter f s =
- let rec s_iter f s = function
- n when n = String.length s -> ()
- | n -> (f s.[n]) ; (s_iter f s (n+1))
- in s_iter f s 0 ;;
- (* 1.3 string_upcase *)
- let string_upcase x = string_iter char_upcase x ;;
- (* 1.4 list_upcase *)
- let rec list_upcase liste =
- let rec list_iter f = function
- [] -> ()
- | e::l -> f e ; print_newline (); list_iter f l
- in list_iter string_upcase liste ;;
- let make_liste =
- let length = Array.length Sys.argv
- in
- let rec aux = function
- n when n = length -> []
- | n -> Sys.argv.(n)::aux (n+1)
- in aux 1 ;;
- let _= list_upcase make_liste ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement