📜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?