add map/lambda samples

This commit is contained in:
Drew Perttula 2018-04-05 15:22:32 -07:00
parent 2405f87fd6
commit 1b49ef96ea
1 changed files with 7 additions and 0 deletions

View File

@ -222,3 +222,10 @@ for line in lines("yourfile.txt"):
echo line echo line
``` ```
### map and lambda
``` Nim
import sequtils # for map
let temperatures = map(locations, getTemperature)
let temperatures = map(locations, proc (loc: Location): float = getTemperature(loc, scale=C))
```
See [manual](https://nim-lang.org/docs/manual.html#procedures-anonymous-procs)