Functional Extensions
This static class contains several overloads to deal with Action
and Func
delegates as extension methods. With this class is possible to use Currying
and PartialApplication
classes as extension methods as well.
Besides that, this class provide an conversion mechanism to cast an Action
into a Func
that returns an Unit
type and vice versa.
Methods
Name
Parameters
Returns
Description
ToFunction
this Action action
Func<Unit>
Casts an action to a function that returns a new instance of Unit.
ToFunction
this Action<T> action
Func<T, Unit>
Casts an action to a function that returns a new instance of Unit.
ToFunction
this Action<T, T2> action
Func<T, T2, Unit>
Converte um delegate Action para um delegate Func, mantendo os mesmos parâmetros e retornando um Unit.
ToFunction
this Action<T, T2, T3> action
Func<T, T2, T3, Unit>
Casts an action to a function that returns a new instance of Unit.
ToFunction
this Action<T, T2, T3, T4> action
Func<T, T2, T3, T4, Unit>
Casts an action to a function that returns a new instance of Unit.
ToAction
this Func<Unit> function
Action
Casts a function that returns Unit to an action.
ToAction
this Func<T, Unit> function
Action<T>
Casts a function that returns Unit to an action.
ToAction
this Func<T, T2, Unit> function
Action<T, T2>
Casts a function that returns Unit to an action.
ToAction
this Func<T, T2, T3, Unit> function
Action<T, T2, T3>
Casts a function that returns Unit to an action.
ToAction
this Func<T, T2, T3, T4, Unit> function
Action<T, T2, T3, T4>
Casts a function that returns Unit to an action.
WARNING
This class contains more than the listed methods, however, all of the non listed methods are just overloads for methods avaible in
Currying
andPartialApplication
as an extension method.
Usage
Different from another classes of this namespace, this class can act as an extension to Func
and Action
C# delegates.
After using the namespace Tango.Functional
you'll be capable of doing all these operations like they are methods of the delegates itselves!
See the code bellow:
It is a casts from one delegate to another in an extremely easy way!
It can help you to uses high order functions when the necessary parameter is from one specific type of delegate!
The Curry and Partial Application operations works very similar to the described in sections: Currying
and PartialApplication
, however, through this class, the methods can be used as an extension.
Podemos realizar tanto o processo de currying quanto de aplicação parcial, conforme código:
The currying and the partial application works just fine, like methods from the delegate itself.
The fundamentals about Currying and Partial Application can be find in Fundamentals > Currying and Partial Application.
Last updated
Was this helpful?