-
Notifications
You must be signed in to change notification settings - Fork 89
Lists and Folding
NN--- edited this page Apr 18, 2012
·
3 revisions
- Category: Lists, Tuples and Options
- Description: This sample shows simple uses of 'Fold' to accumulate a result over a list
- Code:
using Nemerle;
using Nemerle.Collections;
using System;
using System.Console;
def data = [("Cats", 4),
("Dogs", 5),
("Mice", 3),
("Elephants", 2)];
def count = data.Fold(0, ((_, nm), acc) => acc + nm);
WriteLine($"Total number of animals: $count")
- Execution Result:
Total number of animals: 14
[Copyright ©](Terms of use, legal notice)