F# Training
F# Training
F# Training
  • Presentation
  • Fundamentals
    • Introduction
    • Syntax
      • Bases
      • Functions
      • Rules
      • Exceptions
    • First concepts
    • πŸ”Quiz
  • Functions
    • Signature
    • Concepts
    • Syntax
    • Standard functions
    • Operators
    • Addendum
    • πŸ”Quiz
    • πŸ“œSummary
  • Types
    • Overview
    • Tuples
    • Records
    • Unions
    • Enums
    • Anonymous records
    • Value types
    • πŸ“œRecap
    • Addendum
  • Monadic types
    • Intro
    • Option type
    • Result type
    • Smart constructor
    • πŸš€Computation expression (CE)
    • πŸš€CE theoretical basements
    • πŸ“œRecap
  • Pattern matching
    • Patterns
    • Match expression
    • Active patterns
    • πŸš€Fold function
    • πŸ“œRecap
    • πŸ•ΉοΈExercises
  • Collections
    • Overview
    • Types
    • Common functions
    • Dedicated functions
    • πŸ”Quiz
    • πŸ“œRecap
  • Asynchronous programming
    • Asynchronous workflow
    • Interop with .NET TPL
    • πŸ“œRecap
  • Module and Namespace
    • Overview
    • Namespace
    • Module
    • πŸ”Quiz
    • πŸ“œRecap
  • Object-oriented
    • Introduction
    • Members
    • Type extensions
    • Class, Struct
    • Interface
    • Object expression
    • Recommendations
Powered by GitBook
On this page
  • Question 1 - ⏱ 10’’
  • Question 2 - ⏱ 10’’
  • Question 3 - ⏱ 10’’

Was this helpful?

Edit on GitHub
  1. Collections

Quiz

Question 1 - ⏱ 10’’

type Address = { City: string; Country: string }

let format address = $"{address.City}, {address.Country}"

let addresses: Address list = ...

What function should you use to apply the format function to addresses?

A. List.iter()

B. List.map()

C. List.sum()

Answer

A. List.iter() ❌

B. List.map() βœ…

C. List.sum() ❌


Question 2 - ⏱ 10’’

Que vaut [1..4] |> List.head ?

A. [2; 3; 4]

B. 1

C. 4

Answer

A. [2; 3; 4] ❌ (This is the result of List.tail)

B. 1 βœ…

C. 4 ❌ (This is the result of List.last)


Question 3 - ⏱ 10’’

Quelle est la bonne manière d'obtenir la moyenne d'une liste ?

A. [2; 4] |> List.average

B. [2; 4] |> List.avg

C. [2.0; 4.0] |> List.average

Answer

A. [2; 4] |> List.average ❌

πŸ’₯ Error FS0001: List.average does not support the type int, because the latter lacks the required (real or built-in) member DivideByInt

B. [2; 4] |> List.avg

πŸ’₯ Error FS0039: The value, constructor, namespace or type avg is not defined.

C. [2.0; 4.0] |> List.average βœ…

PreviousDedicated functionsNextRecap

Last updated 1 month ago

Was this helpful?

πŸ”