Question

In: Computer Science

Meta Language(ML) has two commonly used data structures(Lists and tuples). Distinguish between two of them and...

Meta Language(ML) has two commonly used data structures(Lists and tuples). Distinguish between two of them and rationalize your argument by the support of code snippet of each.       

Lists

Tuples

How can we concatenate a string in Meta Language(ML)? Also write one coding example of string concatenation.                                                                                                                        

What is meant by right-associative ? Elaborate it using an example.                               

Write a condition in the given blank below using comparison operator to get the require output from this code.                                                                                                                     

  1. Filter(P,nil) = nil
  •           Filter(P,x::xs) = if P(x) then x::Filter(P,xs) else Filter(P,xs) ;
  1. fn x => ____________________________, [1,10,23,8,5,16,3]);
    1. it = [1,8,5,3] : int list

    Solutions

    Expert Solution

    Answer for first question

    Lists
    1. Lists are mutable.
    2. You can change the items on the list and their ordering.
    3. have different types of objects.
    4. A list occupies more memory compared to tuples.
    5. Lists have variable lengths.
    6. Syntax : [ a,h,j ]
    Tuples
    1. They are immutable.
    2. You cannot change the items of tuples and their ordering.
    3. Tuple can also contain different types of objects.
    4. Tuples occupy less memory.
    5. Tuples have fixed lengths.
    6. Syntax : ( a,h,j )

    Answer for second question

    Strings can be concatenated in Meta Language using the ^ operator

    Example:

    Answer for third question

    The associativity is the property that determines how the operator of the same precedence is executed if the parentheses are missing in the expression.
    The evaluation order of the expression is determined by precedence and associativity if the parentheses are missing in the expression.
    The associativity can be:
    Left to right
    Right to left
    For example:
    The operator '=' is used as right-associative in most of the programming languages.
    a = b = c
    First, the value of c is assigned to b and then assign to variable a.
    The operator '^' is right-associative.
    x = 2^3^2
    The above expression will be calculated as:
    x = 2^(3^2)
    x = 2^(9)
    x = 512
    Answer for fourth question

    given,
    filter(P,nil) = nil
    filter(P,x::xs) =
    if P(x) then x::filter(P,xs)
    else filter(P,xs) ;

    The require output form is [1,8,5,3]
    The input list elements is [1,10,23,8,5,16,3]

    In the output, we see the list contains only elements that are less than 10 in the input list.

    So, condition is given using comparison operator to require output below -:

    fn x => (x < 10),[1,10,23,8,5,16,3] ;

    #########PLEASE UPVOTE THE ANSWER########


    Related Solutions

    a. Distinguish between the commonly used methods for protein structure determination and describe the advantages and...
    a. Distinguish between the commonly used methods for protein structure determination and describe the advantages and disadvantages of each. b. Explain why immunoassays are especially useful for detecting and quantifying small amounts of a substance in a complex mixture. c. The octapeptide AVGWRVKS was digested with trypsin. Which method would be most appropriate for separating the resulting peptides: ion exchange or gel filtration chromatography? Explain. Suppose the octapeptide was digested with chymotrypsin instead. What would be the optimal separation technique...
    How would you show two linked lists are equal? (Java for Data Structures and Algorithms)
    How would you show two linked lists are equal? (Java for Data Structures and Algorithms)
    Data Structures has been classified into two based on its data organization. What are they? Explain...
    Data Structures has been classified into two based on its data organization. What are they? Explain with example and neat diagrams and show how the data are organized in them.
    1)How does the variance in the data affect a statistical test’s ability to distinguish between two...
    1)How does the variance in the data affect a statistical test’s ability to distinguish between two means? 2)Explain the difference between parametric and non-parametric tests?
    You are currently trying to decide between two cost structures for your business: one that has...
    You are currently trying to decide between two cost structures for your business: one that has a greater proportion of short-term fixed costs and another that is more heavily weighted to variable costs. Estimated revenue and cost data for each alternative are as follows: Cost Structure Alternative #1 Alternative #2 Selling price per unit $ 50 $ 50 Variable cost per unit 20 15 Short-term fixed costs/year 85,000 90,000 Required: 1. What sales volume, in units, is needed for the...
    The following data were obtained from a study using two separate toothpastes. You used them on...
    The following data were obtained from a study using two separate toothpastes. You used them on the last homework in R. Now you will work with them to compute the ANOVA by hand. Subjects in group I received a fluoride-supplemented toothpaste for one year while those in group II used one without added fluoride. At the end of the trial period the number of cavities needing to be filled was used as the dependant variable. A) Compute an analysis of...
    1. Lisp only has two data structures, what are they and how can a doubly linked...
    1. Lisp only has two data structures, what are they and how can a doubly linked list be created using them? 2. In a language with strong typing, what advantages does static checking have over dynamic checking?
    a.     Distinguish between the terms isotope and allotrope. Give appropriate examples. b. Hydrogen has two naturally...
    a.     Distinguish between the terms isotope and allotrope. Give appropriate examples. b. Hydrogen has two naturally occurring isotopes: normal hydrogen (H), with atomic mass of 1, and deuterium (D), with atomic mass of 2. A mixture containing equal number of moles of H2 and D2 is allowed to effuse down a capillary. What per cent of the molecules effusing first would be D2? c. The two gaseous forms of elemental oxygen are O2 and O3. A mixture containing equal quantities...
    A sealed container of volume 7 m3 has two compartments with a barrier in between them....
    A sealed container of volume 7 m3 has two compartments with a barrier in between them. In one compartment, there is O2 at an initial pressure of 3 atm, initial temperature of 540 K, and volume 3 m3. In the other compartment, there is CO2 at an initial pressure of 5 atm, initial temperature of 430 K, and volume 4 m3. The barrier in the middle is punctured and the two gases mix together. What is the final pressure and...
    Regression analysis is used to analyze data that has two or more variables in order to...
    Regression analysis is used to analyze data that has two or more variables in order to investigate interdependence of the variables. Regression analysis is used in business to predict trends and analyze a variety of data types for business decision-making. Describe the assumptions necessary to conduct statistical tests involving the hypothesized-regression model. Give examples for the practical application of regression analysis in business. Explain how the regression analysis is used to predict future performance of a business.
    ADVERTISEMENT
    ADVERTISEMENT
    ADVERTISEMENT