Last active
August 29, 2015 14:13
-
-
Save ToJans/5f1b1743dadcdf3b6e7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication2 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var ints = new int[] { 1, 2, 3 }; | |
var strings = new string[] { "alice", "bob", "charlie" }; | |
MyList.methods<int>()[0](ints); | |
MyList.methods<string>()[0](strings); | |
} | |
public class MyList | |
{ | |
//[tail,init,reverse,tail] :: [ [a]->[a] ] | |
public static Func<T[], T[]>[] methods<T>() | |
{ | |
Func<T[], T[]> tail = items => items.Skip(1).ToArray(); | |
Func<T[], T[]> init = items => items.Take(1).ToArray(); | |
Func<T[], T[]> reverse = items => items.Reverse().ToArray(); | |
return new Func<T[], T[]>[] { tail, init, reverse, tail }; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment