Skip to content

Using .map

CodingUnit edited this page Dec 27, 2011 · 6 revisions

Using .map

  • Category: Functions - Arrays, Lists, Seqs
  • Description: .map applies a given function to each element in the collection, returning a new collection.
  • Code:
using Nemerle;
using Nemerle.Collections;
using System;
using System.Console;

// can be applied to arrays and sequences as well
def data = [(1, 1, 2001), (2, 2, 2004), (6, 17, 2009)];
def aoList2 = data.Map((a, b, c) => DateTime(c, a, b).ToString("F"));
foreach (i in aoList2) WriteLine(i)
  • Execution Result:
01.01.2001 0:00:00
02.02.2004 0:00:00
17.06.2009 0:00:00
Clone this wiki locally