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

fun main() {     val stringResult = getResult("Kotlin")     val intResult = getResult(100)     // TODO...
fun main() {     val stringResult = getResult("Kotlin")     val intResult = getResult(100)     // TODO 2     println() } // TODO 1 fun <T> getResult(args: T): Int {     return 0 } TODO 1: Create a new generics function with the following conditions: The function name is getResult. Has one type of parameter. If the attached argument is of type Int, then the value returned is the value of the argument multiplied by 5. If the attached argument is...
anwer in kotlin fun main() { val text = "Kotlin".getFirstAndLast() val firstChar = text["first"] val lastChar...
anwer in kotlin fun main() { val text = "Kotlin".getFirstAndLast() val firstChar = text["first"] val lastChar = text["last"] // TODO 2 println() } // TODO 1 fun String.getFirstAndLast() = mapOf<String, Char>() TODO 1: Make the getFirstAndLast function the extension of the String class with the return type Map <String, Char> TODO 2: Add functions to print the values of the firstChar and lastChar variables in the console. there no more information from this task i dont know. this is the...
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...
// TODO 1 class Cat(private val name: String) { var sleep: Boolean = false fun toSleep()...
// TODO 1 class Cat(private val name: String) { var sleep: Boolean = false fun toSleep() { println() } } fun main() { // TODO 2 val gippy = Cat("") gippy.toSleep() gippy.sleep = true gippy.toSleep() } TODO 1: Complete the code in the Cat class with the following conditions: Create a getter setter function for the sleep property in which there is a function to print text: The getter / setter function is called Add code to the toSleep ()...
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...
(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=
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;   ...
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:" <<...
I need this Java code translated into C Code. Thank you. //Logical is the main public...
I need this Java code translated into C Code. Thank you. //Logical is the main public class public class Logical { public static void main(String args[]) { char [][] table= {{'F','F','F'},{'F','F','T'},{'F','T','F'},{'F','T','T'},{'T','F','F'},{'T','F','T'},{'T','T','F'},{'T','T','T'}}; // table contains total combinations of p,q,& r int totalTrue, totalFalse, proposition;    //proposition 1: proposition=1; start(proposition); totalTrue=0; totalFalse=0; for(int i=0;i<8;i++) {    { char o= conjuctive(implecation(negation(table[i][0]),table[i][1]),implecation(table[i][2],table[i][0])); System.out.println(" "+table[i][0]+" "+table[i][1]+" "+table[i][2]+" "+o); if(o=='T') totalTrue++; else totalFalse++;    } } finalOutput(totalTrue,totalFalse,proposition); System.out.println(" "); System.out.println(" ");    //proposition 2: proposition=2; start(proposition);...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT