Update syntax-list-comprehensions.md

This commit is contained in:
James Napora 2022-02-13 16:39:20 -08:00 committed by GitHub
parent e52d036000
commit 14e40671fc
Signed by: DevComp
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,3 +63,15 @@ let vector = c![x, for x in 1..10, if x % 2 == 0];
### Function syntax
List comprehensions could be implemented as functions with ``table.map`` or ``table.filter``
Examples:
#### Perl
```perl
my @doubles = map {$_*2} 1..9;
```
#### Rust
```rust
let ns: Vec<_> = (0..100).filter(|x| x * x > 3).map(|x| 2 * x).collect();
```