-
Notifications
You must be signed in to change notification settings - Fork 89
Lists and MapFiltered
NN--- edited this page Apr 18, 2012
·
3 revisions
- Category: Lists, Tuples and Options
- Description: Project from a list with filtration
- Code:
using Nemerle;
using Nemerle.Collections;
using System;
using System.Console;
def data = [("Cats", 4),
("Bears", 5),
("Mice", 3),
("Elephants", 2)];
def res = data.MapFiltered((x, _) => x.Length <= 4, (x, y) => (x, x.Length, y));
WriteLine($"Count animals with short names: $res")
- Execution Result:
Count animals with short names: [(Cats, 4, 4), (Mice, 4, 3)]
[Copyright ©](Terms of use, legal notice)