add map/lambda samples
This commit is contained in:
parent
2405f87fd6
commit
1b49ef96ea
|
@ -222,3 +222,10 @@ for line in lines("yourfile.txt"):
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue