πŸ“œRecap

Types

5 collections including 4 functional/immutable

List: default choice / Versatile, Practical β†’ [ ], Operators: Cons ::, Append @, Pattern matching

Array: fixed-size, mutable, performance-oriented (e.g. indexer) β†’ [| |] less handy to write than [ ]

Seq: deferred evaluation (Lazy), infinite sequence

Set: unique elements

Map: values by unique key

API

Rich β†’ Hundreds of functions >> Fifty for LINQ

Consistency β†’ Common syntax and functions β†’ Functions preserve the collection type (β‰  LINQ sticked to IEnumerable<>)

Semantic β†’ Function names closer to JS

Comparison Cβ™―, Fβ™―, JavaScript

Cβ™― LINQ

Fβ™―

JS Array

Select(), SelectMany()

map, collect

map(), flatMap()

Any(predicate), All()

exists, forall

some(), every()

Where(), Γ—

filter, choose

filter(), Γ—

First(), FirstOrDefault()

find, tryFind

Γ—, find()

Γ—

pick, tryPick

Γ—

Aggregate([seed]])

fold, reduce

reduce()

Average(), Sum()

average, sum

Γ—

ToList(), AsEnumerable()

List.ofSeq, toSeq

Γ—

Zip()

zip

Γ—

BCL types

  • Array

  • ResizeArray for C# List

  • Dictionaries: dict, readOnlyDict

For interop or performance

πŸ•ΉοΈ Exercises

On Exercism.io / F# track

Exercise
Level
Topics

High Scores

Easy

List

Protein Translation

Medium+

Seq/List πŸ’‘

ETL

Medium

Map of List, Tuple

Grade School

Medium+

Map of List

☝ Pre-requisites: β†’ Create an account, with GitHub for instance β†’ Solve the first exercises to unlock the access to the one above

πŸ’‘ Tips: β†’ string is a Seq<char> β†’ What about Seq.chunkBySize?

πŸ”— Additional resources

Last updated

Was this helpful?