程序代写案例-CSI 519

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
CSI 519 — Spring 2021: Homework 2
Due: Feb 17 before 11:59pm
1. Define a function addnums which takes a list of integers and adds 0 to the leftmost element,
1 to the next one, and so on. Symbolically, given a list [x1, x2, . . . , xn], the function should
return [x1, x2 + 1, x3 + 2, . . . , xn + n− 1].
Any other function you define must be local to the above definition.
- addnums;
val it = fn : int list -> int list
- addnums nil;
val it = [] : int list
- addnums [0,0,0,0];
val it = [0,1,2,3] : int list
- addnums [1,2,3,4,5,6];
val it = [1,3,5,7,9,11] : int list
Practice problem: not for submission
• Define a function samefactorset which takes two non-zero integers m and n and checks
whether their absolute values have the same set of prime factors. For instance, 12 and 18
have the same set of factors, {2, 3}.
You can assume that the inputs will be non-zero. Any other function you define must be
local to the above definition.
- samefactorset(12, 54);
val it = true : bool
- samefactorset(350, ~140);
val it = true : bool
- samefactorset(7007, 91);
val it = false : bool
- samefactorset(1, 64);
val it = false : bool
- samefactorset(1, 1);
val it = true : bool

欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468