Lists and MapFiltered - vilinski/nemerle GitHub Wiki

Lists and MapFiltered

  • 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)