From 14e40671fc5c7c6f70b520c4e2372b48a6589791 Mon Sep 17 00:00:00 2001 From: James Napora <85808999+TheGreatSageEqualToHeaven@users.noreply.github.com> Date: Sun, 13 Feb 2022 16:39:20 -0800 Subject: [PATCH] Update syntax-list-comprehensions.md --- rfcs/syntax-list-comprehensions.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rfcs/syntax-list-comprehensions.md b/rfcs/syntax-list-comprehensions.md index 71830b2e..8708e43b 100644 --- a/rfcs/syntax-list-comprehensions.md +++ b/rfcs/syntax-list-comprehensions.md @@ -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(); +```