Created
October 12, 2017 08:56
-
-
Save battermann/9784791a7646fca702d0472de7f61475 to your computer and use it in GitHub Desktop.
This file contains 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
<#@ template debug="false" hostspecific="false" language="C#" #> | |
<#@ assembly name="System.Core" #> | |
<#@ import namespace="System.Linq" #> | |
<#@ import namespace="System.Text" #> | |
<#@ import namespace="System.Collections.Generic" #> | |
<#@ output extension=".cs" #> | |
//------------------------------------------------------------------------------ | |
// <auto-generated> | |
// This code was generated by a tool. | |
// | |
// Changes to this file may cause incorrect behavior and will be lost if | |
// the code is regenerated. | |
// </auto-generated> | |
//------------------------------------------------------------------------------ | |
using System; | |
namespace Currying | |
{ | |
public static class CurryExtension | |
{ | |
<# | |
for(var i = 2; i <= 16; i++) | |
{ | |
var t = String.Join("", Enumerable.Range(1, i).Select(x => "T" + x + ", ")); | |
var func = String.Join("", Enumerable.Range(1, i).Select(x => "Func<T" + x + ", ")) + "TResult" + new String('>', i); | |
var xarg1 = String.Join("", Enumerable.Range(1, i).Select(x => "x" + x + " => ")); | |
var xarg2 = String.Join(", ", Enumerable.Range(1, i).Select(x => "x" + x)); | |
#> | |
public static <#= func #> Curry<<#= t #> TResult>(this Func<<#= t #> TResult> func) | |
{ | |
return <#= xarg1 #>func(<#= xarg2 #>); | |
} | |
<# } #> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment