*****In SML/NJ******
1. Write a function count_list with type
int list -> int
that returns the number of items in a list. An item that is repeated is counted each time it appears in the list.
2. Write an ML function sum_list with type
int list -> int
that returns the sum of all the elements within a list
3. Write a function countdown with the type
int -> int list
that returns a list of numbers from its argument down to 1.
countdown (5) = [5, 4, 3, 2, 1]
countdown (10) = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
4. Write a function countup with type
int * int -> int list
that takes two arguments (start and finish) and returns a list with all the numbers between start and finish.
countup (1, 10) = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
countup (2, 7) = [2, 3, 4, 5, 6, 7]
5. Write a function find_last with type
int list -> int
that returns the last element in a list:
findlast [1, 3, 5, 7, 9] = 9
findlast [2, 3, 4, 5] = 5
IF YOU HAVE ANY DOUBTS COMMENT BELOW I WILL BE THERE TO HELP YOU
ANSWER:
EXPLANATION:
Answer 1:
If the exclusiveness of the elements in the list is not to be taken into consideration then
(length ( list 1 2 3 4 1))
ELSE
(define (count-unique-elements lst unique-elems
count)
(cond ((null? lst) count)
((member (car lst) unique-elems)
(count-unique-elements (cdr lst) unique-elems count))
(else
(count-unique-elements (cdr lst)
(cons (car lst) unique-elems)
(+ 1 count)))))
(count-unique-elements '(1 2 3 4 5 1 2 3 4 5) '() 0)

Answer 2:
(define (sum-of-elements L)
(apply + L))
(sum-of-elements '(10 9 8 7 6 5 4 3 2 1))

HOPE IT HELPS YOU
RATE THUMBSUP PLEASE
*****In SML/NJ****** 1. Write a function count_list with type int list -> int that returns the...
in ml language or sml
Exercise 14 Write a function maxpairs of type (int * int) list -> int lise 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).
Define a function in SML, called "less" of type int * int list -> int list so that less(e,L) is a list of all the integers in L that are less than e.
1. use python List to Dictionary Write a function that has three parameters: a list of unsorted numbers with no duplicates, a start number, and an end number. This function should return a dictionary with all integers between the start and end number (inclusive) as the keys and their respective indices in the list as the value. If the integer is not in the list, the corresponding value would be None. Example unsorted list: [2,1,10,0,4,3] two numbers: 3, 10 returned...
20. [5 points] Rewrite the following ML. function using patterns fun factn. ifn-0 then 1 else n fact (n-1) 21. [S points) Using map function, write an ML function int2real of type int list real list that takes a list of integers and returns the same numbers converted to real. For example, if the input is [1,2,3], the output should be like [1.0,2.0,3.0 22. [5 points] Using foldr function, write a function duplist of type·a list 'a list that takes...
PYTHON CODE
In a program, write a function that accepts two arguments: a
list, and a number n. Assume that the list contains numbers. The
function should display all of the numbers in the list that are
greater than the number n. Output should look like:
Number: 5 List of numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] List of numbers that are larger than 5: [6, 7, 8, 9, 10]
2. Write a scheme function get-even-nums that accepts a list of numbers and returns a new list that contains only the even numbers. (Hint: use reminder function) Sample runs: (get-even-nums ‘(1 2 3 4 5 6 7 8 9)) should return (8 6 4 2). (get-even-nums ‘(1 3 5 7 9)) should return ’( ).
In SML programming write a function pow of type real * int -> real that raises a real number to an integer power. Your function need not behave well if the integer power is negative.
1. Write a function that converts a string into an int. Assume the int is between 10 and 99. Do not use the atoi() or the stoi() function. 2. Write a function prototype for problem 1. 3. Write a function call for the function you defined in problem 1. 4. Write a function that converts an int between 10 and 99 into a string. 5. Write a function prototype for problem 4. 6. Write a function call for function you...
Python3: Write the function findLongestStreak(lst) which takes a list of numbers, lst, and returns the longest streak of numbers which occur in the list. A streak of numbers is a list of numbers where each number is one greater than the one that occurred before it- for example, [4, 5, 6, 7]. So findLongestStreak([3, 4, 8, 2, 3, 4, 5, 7, 8, 9]) would return [2, 3, 4, 5]. If there is more than one streak with the longest length,...
PYTHON
The first function you will write should be called ‘countDown’.
Your function should take zero (0) arguments. The function should
return one (1) list containing integers from 10 to 1 and finally,
the string “Liftoff!”. (i.e., [10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
‘Liftoff!’]). You function must be recursive (i.e., it should
contain a call to itself within the function body). You will get NO
credit if you use any loops (for, while, etc).
3. Function...