# Functionel Programming - higher-order functions overview
###### tags: `F#`
## Sets higher-order functions
## Lists higher-order functions
**List.fold**
```F#
List.fold (fun acc currentElement -> ) lst
```
```F#
let sum lst =
lst
|> List.fold (fun acc curr -> acc + curr) 0
val sum : lst:int list -> int
sum [2; 4; 6; 8;];;
val it : int = 20
```
List.fold is kinda like a loop
Applies a function to each element of the collection, threading an accumulator argument through the computation. This function takes the second argument, and applies the function to it and the first element of the list. Then, it passes this result into the function along with the second element, and so on. Finally, it returns the final result. If the input function is f and the elements are i0...iN, then this function computes f (... (f s i0) i1 ...) iN.
```F#
('State → 'T → 'State) → 'State → 'T list → 'State
```
**List.map**
builds a new collection whose elements are the results of applying the given function to each of the elements of the collection
```F#
List.map
```
## Maps higher-order functions
let calculatePoints square word = match squares with
|square |> List.mapi(fun i square -> List.map(fun b-> (fst b),(snd b) word i) square)
|> List.fold (fun x y-> x @ y) [] |> List.sortBy(fst) |> List.map(snd) |> List.fold (fun .> )