Question

can someone help me answer the following #Fsharp multiple choice questions along with explanations for each...

can someone help me answer the following #Fsharp multiple choice questions along with explanations for each question please.

7. How does F# interpret the type int * bool -> string list? Select one:

a. (int * (bool -> string)) list

b. ((int * bool) -> string) list

c. int * (bool -> (string list))

d. (int * bool) -> (string list)

8. Let F# function foo be defined as follows:

let rec foo = function

| (xs, []) -> xs | (xs, y::ys) -> foo (xs@[y], ys)

If foo is supposed to append its two list parameters, which of the following is true? Select one:

a. foo fails Step 1 of the Checklist for Programming with Recursion.

b. foo fails Step 2 of the Checklist for Programming with Recursion.

c. foo fails Step 3 of the Checklist for Programming with Recursion.

d. foo satisfies all three steps of the Checklist for Programming with Recursion.

11. Which of the following is the type that F# infers for (fun f -> f 17)? Select one:

a. ('a -> 'b) -> 'b

b. (int -> int) -> int

c. (int -> 'a) -> 'a

d. ('a -> 'a) -> 'a

12. Which of the following has type int -> int list? Select one:

a. (@) [5]

b. [fun x -> x+1]

c. fun x -> 5::x

d. fun x -> x::[5]

13. What type does F# infer for the expression (3, [], true) ? Select one:

a. int * 'a list * bool

b. int * 'a * bool

c. int * int list * bool

d. Type error.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

How does F# interpret the type int * bool -> string list? Select one:

Answer:
a. (int * (bool -> string)) list

Explantion:

Because here the first string is going to get validate and then it is taken by the int finally convert to list.

8.let rec foo = function

| (xs, []) -> xs | (xs, y::ys) -> foo (xs@[y], ys)

If foo is supposed to append its two list parameters, foo satisfies all three steps of the Checklist for Programming with Recursion.

Answer: D

11. F# infers for (fun f -> f 17)

Answer:

b. (int -> int) -> int

12. Which of the following has type int -> int list?

Answer:

c. fun x -> 5::x

13. F# infer for the expression (3, [], true)

Answer:D

d. Type error.


Have a great day.

Add a comment
Know the answer?
Add Answer to:
can someone help me answer the following #Fsharp multiple choice questions along with explanations for each...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help me to answer the 5 programming questions and give some specific explanations, thanks a...

    Please help me to answer the 5 programming questions and give some specific explanations, thanks a lot !!! Question 5 In the following method, describe which variables are thread-safe and which are not thread-safe and why. Not yet answered public int wasSoHard (int x, String in, Array List<Integer> stuff) { Marked out of char c in.charAt (x) 3.00 P Flag question for (int i= 0; i < in.length); i if (in.charAt (i) == c) { stuff.add (i); return stuff .size()...

  • Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS:...

    Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS: it is for a yahtzee game program. Write function sumChance to do the following a. Return type int b. Parameter list array of dice c. Declare int variable sum d. Declare int variable die e. Loop through the dice array adding the value of each die to the variable sum f. Return variable sum Write function checkLgStraight to do the following a. Return type...

  • Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS:...

    Can someone let me know what to do for this? In C Programming. HERE ARE INSTRUCTIONS: Write function sum Category to do the following a. Return type int b. Parameter list i. int array dice ii. int value category c. Declare int variable sum d. Declare int variable die e. Loop through the dice array i. Based on the selected category check if the value of the current die matches the category (i.e. user selected ONE for category, die value...

  • I need help on this Systems review please! it's due by midnight monday. Question 1 Not...

    I need help on this Systems review please! it's due by midnight monday. Question 1 Not yet answered Points out of 1.00 Flag question Question text Using these declarations: int * numberPointers[3]; int * pointer; int number; Which of the following statements would generate a warning or error? Select one: a. number = pointer; b. *pointer = number; c. pointer = numberPointers; d. numberPointers[2] = &number; e. a., b., and d. f. a. and c. Question 2 Not yet answered...

  • Can someone help me with my code.. I cant get an output. It says I do...

    Can someone help me with my code.. I cant get an output. It says I do not have a main method. HELP PLEASE. The instruction are in bold on the bottom of the code. package SteppingStones; //Denisse.Carbo import java.util.Scanner; import java.util.ArrayList; import java.util.List; public class SteppingStone5_Recipe { private String recipeName; private int servings; private List<String> recipeIngredients; private double totalRecipeCalories; public String getRecipeName() { return recipeName; } public void setRecipeName (string recipeName){ this.recipeName = recipeName; } public int getServings() { return...

  • PLEASE USE F# PROGRAMMING LANGUAGE: NO LOOPS OR CORE LIBRARY FUNCTIONS. ONLY USE RECURSION. Problem 3...

    PLEASE USE F# PROGRAMMING LANGUAGE: NO LOOPS OR CORE LIBRARY FUNCTIONS. ONLY USE RECURSION. Problem 3 (10 pts) Define a function rev that takes a list xs and returns it in the reverse order. • F# standard library has List.rev, do not use it. You need to reimplement it. In [ ]: let rev (xs: 'a list) In [ ]: // Test you function List.rev [] = rev [] |> printfn "%" List.rev [1..9] = rev [1..9] |> printfn "%b'...

  • Haskell coding problem please do problem two Here is problem one for the types Problem Two (Polymorphic Type Inference...

    Haskell coding problem please do problem two Here is problem one for the types Problem Two (Polymorphic Type Inference): Give the type of the following functions in the space indicated. Assume that we have only the types given in Problem One, plus Haskell's built-in types Integer and Bool. Assume that all arithmetic operators take only Integer, e.g., () is Integer -> Integer -> Integer. test :: test x xs = (Cons x (Cons (x+1) xs)) second second xs = f...

  • Three of these function overloads are considered identical by the compiler and would conflict with each...

    Three of these function overloads are considered identical by the compiler and would conflict with each other. The other would be considered different- choose the one that is considered different from others. Int foo ( int x, double y ) ; Int foo ( double x, int y ) ; Void foo ( int x, double y ) ; Int foo ( int day, double temp ) ; Consider the following incomplete code: Int f ( int number ) }...

  • Please help me to answer the 5 programming questions and give some specific explanations, thanks a...

    Please help me to answer the 5 programming questions and give some specific explanations, thanks a lot !!! Question Consider a class hierarchy that includes a class called Creature, with subclasses called Unicorn and Dragon. The Creature class has a method called feelsLike, Not yet answered which is overridden in the Unicorn and Dragon class. Marked out of The feelsLike method of the Creature class returns "smooth", while the feelsLike method is overridden in the Unicorn class to return "fluffy"...

  • Practice Problem 23.50 Starting with cyclopentene and using any other reagents of your choice, show how...

    Practice Problem 23.50 Starting with cyclopentene and using any other reagents of your choice, show how you would make each of the following compounds: (a) (b) (c) HO OH Choose from the following list of reagents: c b d Pd[OAC)2, PPhy, BN NaOH, H20, heat H,0NaOH (xs) CH2CH2 f g e BHy-THF (xs) CHşlyZn-Cu. Et, BCOM) h Grubbs catalyst i k - BE Be Using the reagents above, list in order (by letter, no period) those necessary to provide each...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT