Question

In: Computer Science

ANSWER WITH ML CODE PLZ. NOT C++ 1) fun main() = let val yy = [6,4,2,0];...

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;

Solutions

Expert Solution

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

>> 

Related Solutions

C CODE PLZ! All instructions for what to do in code #include <stdio.h> int main(int argc,...
C CODE PLZ! All instructions for what to do in code #include <stdio.h> int main(int argc, char **argv) { int n, k, l, r, t, d, i; char str[65]; /* Make the user enter a non-negative integer */ printf("Please enter a non-negative integer: "); scanf("%d", &n); while (n < 0) { printf("Sorry, your input is incorrect.\n"); printf("Please enter a non-negative integer: "); scanf("%d", &n); } /* Convert the integer to reversed binary: e.g. 6 gets converted to 011 */ if...
Write a C code to let the main thread create N child threads, where each created...
Write a C code to let the main thread create N child threads, where each created thread will randomly generate an integer between 0 to 10 and put it into a global array variable. After that, the main thread will calculate the sum of all the generated integers. N should be input as a command line argument. Complete the following C code by filling all “???”s in the code sketch. NOTE: when you compile the code, you need to add...
Plz convert this C++ code into JAVA code thanks #include<iostream> using namespace std; //function for calculating...
Plz convert this C++ code into JAVA code thanks #include<iostream> using namespace std; //function for calculating the average sightings from the Total Sightings array float calcAverage(float totalSightings[],int n) {    int i;    float sum=0.0;    for(i=0;i<n;i++)    sum=sum+totalSightings[i];    return sum/n; } int main() {    // n is no. of bird watchers    //flag , flag2 and flag3 are for validating using while loops    int n,i,flag,flag2,flag3;       //ch also helps in validating    char ch;   ...
(1 point) Given the following data set, let xx be the explanatory variable and yy be...
(1 point) Given the following data set, let xx be the explanatory variable and yy be the response variable. xx 5 7 6 2 8 7 8 yy 7 4 4 9 3 3 2 (a) If a least squares line was fitted to this data, what percentage of the variation in the yy would be explained by the regression line? (Enter your answer as a percent.) ANSWER: % (b) Compute the correlation coefficient: r=
convert following C++ code into MIPS assembly: int main() {                                 &
convert following C++ code into MIPS assembly: int main() {                                         int x[10], occur, count = 0;                                                              cout << "Type in array numbers:" << endl; for (int i=0; i<10; i++) // reading in integers                               { cin >> x[i];        } cout << "Type in occurrence value:" << endl;                                 cin >> occur;                                                 // Finding and printing out occurrence indexes in the array                                  cout << "Occurrences indices are:" <<...
3. Translate the following C code to MIPS assembly code (in two separate files). int main()...
3. Translate the following C code to MIPS assembly code (in two separate files). int main() { printf(“before subroutine!\n”); Subfunc(); printf(“after subroutine!\n!”); } void Subfunc() {printf(“I am subroutine!\n”);} Submission file: Lab4_3a.asm for the main routine and Lab4_3b.asm for the sub-routine.
3. Translate the following C code to MIPS assembly code (in two separate files). int main()...
3. Translate the following C code to MIPS assembly code (in two separate files). int main() { printf(“before subroutine!\n”); Subfunc(); printf(“after subroutine!\n!”); } void Subfunc() {printf(“I am subroutine!\n”);} 4. Translate the following C code to MIPS assembly (in two separate files). Run the program step by step and observe the order of instructions being executed and the value of $sp. int main() { int x=2; z=Subfunc(x); printf(“Value of z is: %d”, z); } int Subfunc(int x) { return x+1;}
Write the code in C++. Write a program to implement Employee Directory. The main purpose of...
Write the code in C++. Write a program to implement Employee Directory. The main purpose of the class is to get the data, store it into a file, perform some operations and display data. For the purpose mentioned above, you should write a template class Directory for storing the data empID(template), empFirstName(string), empLastName(string), empContactNumber(string) and empAddress(string) of each Employee in a file EmployeeDirectory.txt. 1. Write a function Add to write the above mentioned contact details of the employee into EmployeeDirectory.txt....
Translate the following C code to MIPS assembly. The main function and subfunction are translated to...
Translate the following C code to MIPS assembly. The main function and subfunction are translated to two separate .asm files. Finish the assembly code segment for the above requirement. int main() { int x=2; int y=1; int z=0; z=Subfunc(x,y); printf(“Value of z is: %d”, z); } int Subfunc(int x, int y) { int t1=0; t1=x+y+100; return t1;} File 1: .data str: .asciiz "The value of z:" .text #.globl main main: addi $s0, $0,2 #x addi $s1, $0,1 #y addi $s2,...
Please convert the following C program into the RISC-V assembly code 1) #include <stdio.h> int main()...
Please convert the following C program into the RISC-V assembly code 1) #include <stdio.h> int main() { int i = 2, j = 2 + i, k; k = i * j; printf("%d\n", k + j); return 0; } 2) #include <stdio.h> int main() { int i = 2, j = 2 + i, k = j / 2; if (k == 1) { printf("%d\n", j) k = k * 2; if ( k == j) { printf("%d\n|, j); }...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT