My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#region Copyright
// *******************************************************************************
// Copyright (c) 2000-2009 Paul Stancer.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// Contributors:
// Paul Stancer - initial implementation
// *******************************************************************************
#endregion
#region using
using System;
using System.Text;
using System.IO;
using System.Security;
using System.Reflection;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.CompilerServices;

using System.Threading;

using Ximura;
#endregion // using
namespace Ximura
{
public static partial class LinqHelper
{
#region Curry<T1, TResult>(this Func<T1, TResult> f)
/// <summary>
/// This method curries the function to return a new function with the first parameter T1 wrapped in the new function.
/// </summary>
/// <typeparam name="T1">Parameter 1</typeparam>
/// <typeparam name="TResult">The parameter result from the function.</typeparam>
/// <param name="f">The function to be curried.</param>
/// <returns>Returns a new function with the T1 parameter contained in the new function.</returns>
public static Func<T1, Func<TResult>> Curry<T1, TResult>(this Func<T1, TResult> f)
{
return p1 => () => f(p1);
}
#endregion // Curry<T1, TResult>(this Func<T1, TResult> f)
#region Curry<T1, T2, TResult>(this Func<T1, T2, TResult> f)
/// <summary>
/// This method curries the function to return a new function with the first parameter T1 wrapped in the new function.
/// </summary>
/// <typeparam name="T1">Parameter 1</typeparam>
/// <typeparam name="T2">Parameter 2</typeparam>
/// <typeparam name="TResult">The parameter result from the function.</typeparam>
/// <param name="f">The function to be curried.</param>
/// <returns>Returns a new function with the T1 parameter contained in the new function.</returns>
public static Func<T1, Func<T2, TResult>> Curry<T1, T2, TResult>(this Func<T1, T2, TResult> f)
{
return p1 => p2 => f(p1, p2);
}
#endregion // Curry<T1, T2, TResult>(this Func<T1, T2, TResult> f)
#region Curry<T1, T2, T3, TResult>(this Func<T1, T2, T3, TResult> f)
/// <summary>
/// This method curries the function to return a new function with the first parameter T1 wrapped in the new function.
/// </summary>
/// <typeparam name="T1">Parameter 1</typeparam>
/// <typeparam name="T2">Parameter 2</typeparam>
/// <typeparam name="T3">Parameter 3</typeparam>
/// <typeparam name="TResult">The parameter result from the function.</typeparam>
/// <param name="f">The function to be curried.</param>
/// <returns>Returns a new function with the T1 parameter contained in the new function.</returns>
public static Func<T1, Func<T2, T3, TResult>> Curry<T1, T2, T3, TResult>(this Func<T1, T2, T3, TResult> f)
{
return p1 => (p2, p3) => f(p1, p2, p3);
}
#endregion // Curry<T1, T2, T3, TResult>(this Func<T1, T2, T3, TResult> f)
#region Curry<T1, T2, T3, T4, TResult>(this Func<T1, T2, T3, T4, TResult> f)
/// <summary>
/// This method curries the function to return a new function with the first parameter T1 wrapped in the new function.
/// </summary>
/// <typeparam name="T1">Parameter 1</typeparam>
/// <typeparam name="T2">Parameter 2</typeparam>
/// <typeparam name="T3">Parameter 3</typeparam>
/// <typeparam name="T4">Parameter 4</typeparam>
/// <typeparam name="TResult">The parameter result from the function.</typeparam>
/// <param name="f">The function to be curried.</param>
/// <returns>Returns a new function with the T1 parameter contained in the new function.</returns>
public static Func<T1, Func<T2, T3, T4, TResult>> Curry<T1, T2, T3, T4, TResult>(this Func<T1, T2, T3, T4, TResult> f)
{
return p1 => (p2, p3, p4) => f(p1, p2, p3, p4);
}
#endregion // Curry<T1, T2, T3, T4, TResult>(this Func<T1, T2, T3, T4, TResult> f)

#region Curry<T1>(this Action<T1> f)
/// <summary>
/// This method curries the action to return a new action with the first parameter T1 wrapped in the new action.
/// </summary>
/// <typeparam name="T1">Parameter 1</typeparam>
/// <param name="f">The action to be curried.</param>
/// <returns>Returns a new action with the T1 parameter contained in the new function.</returns>
public static Func<T1, Action> Curry<T1>(this Action<T1> f)
{
return p1 => () => f(p1);
}
#endregion // Curry<T1>(this Action<T1> f)
#region Curry<T1, T2>(this Action<T1, T2> f)
/// <summary>
/// This method curries the action to return a new action with the first parameter T1 wrapped in the new action.
/// </summary>
/// <typeparam name="T1">Parameter 1</typeparam>
/// <typeparam name="T2">Parameter 2</typeparam>
/// <param name="f">The action to be curried.</param>
/// <returns>Returns a new action with the T1 parameter contained in the new function.</returns>
public static Func<T1, Action<T2>> Curry<T1, T2>(this Action<T1, T2> f)
{
return p1 => p2 => f(p1, p2);
}
#endregion // Curry<T1, T2>(this Action<T1, T2> f)
#region Curry<T1, T2, T3>(this Action<T1, T2, T3> f)
/// <summary>
/// This method curries the action to return a new action with the first parameter T1 wrapped in the new action.
/// </summary>
/// <typeparam name="T1">Parameter 1</typeparam>
/// <typeparam name="T2">Parameter 2</typeparam>
/// <typeparam name="T3">Parameter 3</typeparam>
/// <param name="f">The action to be curried.</param>
/// <returns>Returns a new action with the T1 parameter contained in the new function.</returns>
public static Func<T1, Action<T2, T3>> Curry<T1, T2, T3>(this Action<T1, T2, T3> f)
{
return p1 => (p2, p3) => f(p1, p2, p3);
}
#endregion // Curry<T1, T2, T3>(this Action<T1, T2, T3> f)
#region Curry<T1, T2, T3, T4>(this Action<T1, T2, T3, T4> f)
/// <summary>
/// This method curries the action to return a new action with the first parameter T1 wrapped in the new action.
/// </summary>
/// <typeparam name="T1">Parameter 1</typeparam>
/// <typeparam name="T2">Parameter 2</typeparam>
/// <typeparam name="T3">Parameter 3</typeparam>
/// <typeparam name="T4">Parameter 4</typeparam>
/// <param name="f">The action to be curried.</param>
/// <returns>Returns a new action with the T1 parameter contained in the new function.</returns>
public static Func<T1, Action<T2, T3, T4>> Curry<T1, T2, T3, T4>(this Action<T1, T2, T3, T4> f)
{
return p1 => (p2, p3, p4) => f(p1, p2, p3, p4);
}
#endregion // Curry<T1, T2, T3, T4>(this Action<T1, T2, T3, T4> f)
}
}

Change log

r228 by pstancer on Jul 17, 2011   Diff
Update to settings and clean up of code.
Go to: 
Project members, sign in to write a code review

Older revisions

r174 by pstancer on Mar 30, 2010   Diff
Expanded CommandContainer, with
changes to persistence layer.
r164 by pstancer on Mar 24, 2010   Diff
Fixed a few additional namespace
issues to rationalise the project
structure.
r162 by kord.manny on Mar 24, 2010   Diff
Rationalised namespaces for Ximura
All revisions of this file

File info

Size: 7767 bytes, 149 lines
Powered by Google Project Hosting