Question: Write all functions in ML language and Solution to each of these exercises should be just one line of code. Question: Write a function inclist
Write all functions in ML language and Solution to each of these exercises should be just one line of code.
Question: Write a function inclist of type int list -> int -> int list, that takes a list of integers and an integer increment, and returns the same list of integers but with the integers increment added to each one. For example, if you evaluate inclist [1, 2, 3, 4] 10 you should get [11, 12, 13, 14]. Note that the function is curried.
Question) Write a function squarelist of type int list -> int list that takes a list of integers and returns the list of the squares of those integers. For example, if you evaluate squarelist [1,2,3,4] you should get [1,4,9,16]. Question) Write a function truecount of type bool list - > int that takes a list of boolean values and returns the number of trues in the list.
Question) Write a function maxpairs of type (int * int) list -> int list that takes a list of pairs of integers and returns the list of the max elements from each pair. For example, if you evaluate maxpairs [ (1, 3), (4, 2), (~3, ~4) ] you should get [3, 4, ~3].
Question) Write a function concat of type 'a list list - > 'a list that takes a list of lists as a input and returns the list formed by appending the input lists together in order. For example, if the input in [[1, 2], 3 , 4 , 5 , 6], [7 ]] , your function should return [ 1 , 2 , 3, 4 , 5, 6 , 7 ]. (There is a predefined function like this called concat, which of course you should not use.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
