πQuiz
7 questions to apply what we've seen regarding functions
1. How to define the return value (v) of a function (f)? β± 10''
v) of a function (f)? β± 10''A. Simply name the value result.
B. End the function with return v.
C. Do f = v
D. v is the last line of f.
2. How to write an add function taking 2 strings and returning an int? β± 20ββ
add function taking 2 strings and returning an int? β± 20ββA. let add a b = a + b
B. let add (a: string) (b: string) = (int a) + (int b)
C. let add (a: string) (b: string) : int = a + b
3. What does this code: add >> multiply? β± 10ββ
add >> multiply? β± 10ββA. Create a pipeline
B. Define a named function
C. Compose 2 functions
4. Find the name of these functions from FSharp.Core β± 60ββ
A. let ? _ = ()
B. let ? x = x
C. let ? f x = f x
D. let ? x f = f x
E. let ? f g x = g (f x)
π‘ Tips: These may be operators.
5. Describe the following functions in terms of the number of parameters, their type, the return type β± 60ββ
A. int -> unit
B. unit -> int
C. string -> string -> string
D. ('T -> bool) -> 'T list -> 'T list
6. What is the signature of the h function below? β± 30ββ
h function below? β± 30ββA. int -> int
B. int -> string
C. int -> int -> string
D. int -> int -> int
7. What value returns f 2? β± 10ββ
f 2? β± 10ββA. 1
B. 3
C. -1
Last updated
Was this helpful?