-
Notifications
You must be signed in to change notification settings - Fork 89
List to Tuple
NN--- edited this page Apr 18, 2012
·
4 revisions
- Category: Lists, Tuples and Options
- Description: This sample convert a list to a tuple
- Code:
using Nemerle;
using System;
using System.Console;
def listToTuple(lst)
{
def type = Type.GetType($"Nemerle.Builtins.Tuple`$(lst.Length), Nemerle");
def type = type.MakeGenericType(lst.MapToArray(_.GetType()));
Activator.CreateInstance(type, lst.ToArray());
}
def result = listToTuple([1, 2, 3, 4]);
WriteLine(result)
- Execution Result:
(1, 2, 3, 4)
[Copyright ©](Terms of use, legal notice)