-
Notifications
You must be signed in to change notification settings - Fork 89
Lists and 'map'
NN--- edited this page Apr 18, 2012
·
6 revisions
- Category: Lists, Tuples and Options
- Description: This sample shows simple uses of 'Map'
- Code:
using Nemerle;
using System;
using System.Console;
def data = [1, 2, 3, 4];
def result1 = data.Map(_ + 1);
def result2 = data.Map(_.ToString());
def result3 = data.Map(x => (x, x));
WriteLine($"Adding '1' using map = $result1");
WriteLine($"Converting to strings using map = $result2" );
WriteLine($"Tupling up using map = $result3")
- Execution Result:
Adding '1' using map = [2, 3, 4, 5]
Converting to strings using map = [1, 2, 3, 4]
Tupling up using map = [(1, 1), (2, 2), (3, 3), (4, 4)]
[Copyright ©](Terms of use, legal notice)