In: Computer Science
ANSWER WITH ML CODE PLZ. NOT C++
1)
fun main() = let
val yy = [6,4,2,0];
in print (PolyML.makestring (
***(Remove the first item from yy)******
)) end;
2)
fun main() = let
val yy = [6,4,2,0];
in print (PolyML.makestring (
***(Make a list containing only the first item of yy )***
)) end;
3)
fun main() = let
val yy = [8,6,4,2,0];
in print (PolyML.makestring (
***(Prepend 5 to the front of yy)***
)) end;
4)fun main() = let
val yy = [8,6,4];
in print (PolyML.makestring (
***(Prepend [2,5] to the front of yy )***
)) end;
5) fun main() = let
val yy = [8,6,4,2];
in print (PolyML.makestring (
***(Remove the third integer from yy )***
)) end;
Following is the code, in file five_ques.m :
%
% 1.
%
fprintf("\n**** Question 1 ****\n");
yy = [6 4 2 0]
yy(1) = []
%
% 2.
%
fprintf("\n**** Question 2 ****\n");
yy = [6 4 2 0]
yy = [yy(1)]
%
% 3.
%
fprintf("\n**** Question 3 ****\n");
yy = [8 6 4 2 0]
yy = [5 yy]
%
% 4.
%
fprintf("\n**** Question 4 ****\n");
yy = [8 6 4]
yy = [2 5 yy]
%
% 5.
%
fprintf("\n**** Question 5 ****\n");
yy = [8 6 4 2]
yy(3) = []
Following is the output :
>>
>>
>> five_ques
**** Question 1 ****
yy =
6 4 2 0
yy =
4 2 0
**** Question 2 ****
yy =
6 4 2 0
yy =
6
**** Question 3 ****
yy =
8 6 4 2 0
yy =
5 8 6 4 2 0
**** Question 4 ****
yy =
8 6 4
yy =
2 5 8 6 4
**** Question 5 ****
yy =
8 6 4 2
yy =
8 6 2
>>