Lists and Indexed Iteration - vilinski/nemerle GitHub Wiki

Lists and Indexed Iteration

  • Category: Lists, Tuples and Options
  • Description: This sample shows simple uses of 'IterI' and foreach operator
  • Code 1:
using System.Console;

def data = ["Cats", "Dogs", "Mice", "Elephants"];
foreach (x in data with i)
  WriteLine($"item $i: $x");
  • Code 2:
using System.Console;

def data = ["Cats", "Dogs", "Mice", "Elephants"];
data.IterI((i, x) => WriteLine($"item $i: $x"))
  • Execution Result:
item 0: Cats
item 1: Dogs
item 2: Mice
item 3: Elephants

[Copyright ©](Terms of use, legal notice)