1
0
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:
Alexander Medvednikov 2022-02-19 12:10:12 +03:00 committed by GitHub
parent bcc4de19fc
commit 3fa6622ee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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']
``` ```