mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
doc: simplify the filter/map
example a bit
This commit is contained in:
parent
bcc4de19fc
commit
3fa6622ee8
@ -1174,10 +1174,8 @@ the `it` built-in variable to achieve a classic `map/filter` functional paradigm
|
|||||||
|
|
||||||
```v
|
```v
|
||||||
// using filter, map and negatives array slices
|
// using filter, map and negatives array slices
|
||||||
a := ['pippo.jpg', '01.bmp', '_v.txt', 'img_02.jpg', 'img_01.JPG']
|
files := ['pippo.jpg', '01.bmp', '_v.txt', 'img_02.jpg', 'img_01.JPG']
|
||||||
res := a.filter(it#[-4..].to_lower() == '.jpg').map(fn (w string) string {
|
filtered := files.filter(it#[-4..].to_lower() == '.jpg').map(it.to_upper())
|
||||||
return w.to_upper()
|
|
||||||
})
|
|
||||||
// ['PIPPO.JPG', 'IMG_02.JPG', 'IMG_01.JPG']
|
// ['PIPPO.JPG', 'IMG_02.JPG', 'IMG_01.JPG']
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user