-
Notifications
You must be signed in to change notification settings - Fork 89
Using Where
NN--- edited this page Apr 11, 2012
·
3 revisions
- Category: Functions - Arrays, Lists, Seqs
- Description: Where applies a given function to the collection, returning an element x where the function evaluates to true.
- Code:
using System;
using System.Console;
using Nemerle;
using System.Linq;
def numbers = Enumerable.Range(1, 20);
def evens = numbers.Where(x => x % 2 == 0);
WriteLine($"numbers = ..$numbers");
WriteLine($"evens = ..$evens" )
- Execution Result:
numbers = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
evens = 2, 4, 6, 8, 10, 12, 14, 16, 18, 20
[Copyright ©](Terms of use, legal notice)