Skip to content

Instantly share code, notes, and snippets.

@battermann
Created October 12, 2017 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save battermann/9784791a7646fca702d0472de7f61475 to your computer and use it in GitHub Desktop.
Save battermann/9784791a7646fca702d0472de7f61475 to your computer and use it in GitHub Desktop.
<#@ 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