CSE 340留学生辅导、讲解python/CS编程设计、辅导java/c++
- 首页 >> Python编程Arizona State University
CSE 340 – Fall 2018
Homework 5
Due Wednesday November 21 by 11:59 PM
For each of the following definitions, give the type of the function and its arguments. If there is a type
mismatch, you should explain the reason for the mismatch. Note that for recursive functions, let rec
is used.
a. let f a = 1.1:
b. let f a = a 1
c. let f a b = a.(b) + 1.0
d. let f a b = a.(b) + b + 1.0
e. let f a b c = c.(a+b)
f. let f a b = a b
g. let f a b = a b + b a
h. let f a b = a (b (a))
i. let f a b c = c.(a+b) + a
j. let f a b c = if c.(a) > c.(b) then a else b
k. let f a b c = if c.(a.(b)) then a else b
l. let f a b c = a.(c) <= b +1
m. let rec max l = match l with
| [] -> raise Emptylist (* empty list exception *)
| h::[] -> h (* one element list *)
| h::t -> if h > (max t) then (* more than 1 element *)
h
else
(max t)
n. let f a b = if a b then a else b
o. let rec f a g = if a = 0 then 1 else g (f (a-1) g ) a
for what function g does the function f computes the factorial of a?
Define the function g