Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

** I Need help with the following questions on my F# Review with explanation ple

ID: 3881372 • Letter: #

Question

** I Need help with the following questions on my F# Review with explanation please! :) **

4) Which of the following statements about F# lists is not true? Select one:

a) They are immutable.

b) Their built-in functions are polymorphic.

c) They can be of any length.

d) They can be heterogeneous.

5) Which of the following F# expressions evaluates to [1; 2; 3]? Select one:

a) 1::2::3::[]

b) 1@2@3@[]

c) [1; 2; 3]::[]

d) ((1::2)::3)::[]

6) How does F# interpret the expression List.map List.head foo @ baz? Select one:

a) (List.map List.head) (foo @ baz)

b) ((List.map List.head) foo) @ baz

c) List.map (List.head (foo @ baz))

d) (List.map (List.head foo)) @ baz

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:

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.

9) 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

10) 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]

Explanation / Answer

If you have any problem with the answer just let me know in the comments and I'll try to solve it as soon as possible. Also we are required to do only four parts of a question so please do not down vote.

4. Multi methods and polymorphic methods and lists are not available in f#. Hence the correct option is b) Their built-in functions are polymorphic.

5. Lists can be initialized in two ways first [1;2;3;4] and second 1::2::3::[] hence the correct option is a) 1::2::3::[].

6.list.map is used to copy elements of list in another list. And Foo @ Bas are two list concatenated together, the given function copies list head in new list. And correct way to do so is List.map (List.head (foo @ baz)), hence the correct option is(c) List.map (List.head (foo @ baz)).

7. The correct option is d) (int * bool) -> (string list)as it is the correct format.