# Partial Application

> [`Tango.Functional.PartialApplication`](https://github.com/gabrielschade/Tango/blob/master/Tango/Tango/Functional/PartialApplication.cs)

This *static* class contains several overloads for the Partial Application operation, where each overload deals with functions that contains different amounts of parameters, with or without a return.

## Methods

| Name         | Parameters                                                                                                                  | Returns                    | Description                                                                 |
| ------------ | --------------------------------------------------------------------------------------------------------------------------- | -------------------------- | --------------------------------------------------------------------------- |
| PartialApply | <p>Func\<T, TResult> function</p><p>T parameter</p>                                                                         | Func\<TResult>             | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Func\<T, T2, TResult> function</p><p>T parameter</p><p>T2 parameter2</p>                                                 | Func\<TResult>             | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Func\<T, T2, TResult> function</p><p>T parameter</p>                                                                     | Func\<T2,TResult>          | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Func\<T, T2, T3, TResult> function</p><p>T parameter</p><p>T2 parameter2</p><p>T3 parameter3</p>                         | Func\<TResult>             | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Func\<T, T2, T3, TResult> function</p><p>T parameter</p><p>T2 parameter2</p>                                             | Func\<T3, TResult>         | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Func\<T, T2, T3, TResult> function</p><p>T parameter</p>                                                                 | Func\<T2, T3, TResult>     | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Func\<T, T2, T3, T4, TResult> function</p><p>T parameter</p><p>T2 parameter2</p><p>T3 parameter3</p><p>T4 parameter4</p> | Func\<TResult>             | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Func\<T, T2, T3, T4, TResult> function</p><p>T parameter</p><p>T2 parameter2</p><p>T3 parameter3</p>                     | Func\<T4, TResult>         | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Func\<T, T2, T3, T4, TResult> function</p><p>T parameter</p><p>T2 parameter2</p>                                         | Func\<T3, T4, TResult>     | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Func\<T, T2, T3, T4, TResult> function</p><p>T parameter</p>                                                             | Func\<T2, T3, T4, TResult> | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Action\<T> action</p><p>T parameter</p>                                                                                  | Action                     | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Action\<T, T2> action</p><p>T parameter</p><p>T2 parameter2</p>                                                          | Action                     | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Action\<T, T2> action</p><p>T parameter</p>                                                                              | Action\<T2>                | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Action\<T, T2, T3> action</p><p>T parameter</p><p>T2 parameter2</p><p>T3 parameter3</p>                                  | Action                     | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Action\<T, T2, T3> action</p><p>T parameter</p><p>T2 parameter2</p>                                                      | Action\<T3>                | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Action\<T, T2, T3> action</p><p>T parameter</p>                                                                          | Action\<T2, T3>            | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Action\<T, T2, T3, T4> function</p><p>T parameter</p><p>T2 parameter2</p><p>T3 parameter3</p><p>T4 parameter4</p>        | Action                     | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Action\<T, T2, T3, T4> function</p><p>T parameter</p><p>T2 parameter2</p><p>T3 parameter3</p>                            | Action\<T4>                | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Action\<T, T2, T3, T4> function</p><p>T parameter</p><p>T2 parameter2</p>                                                | Action\<T3, T4>            | Creates a new function by partial applies the parameters into the function. |
| PartialApply | <p>Action\<T, T2, T3, T4> function</p><p>T parameter</p>                                                                    | Action\<T2, T3, T4>        | Creates a new function by partial applies the parameters into the function. |

## Usage

The overloads available in this class can be used to create new functions from existing functions as well as Currying class.

In this example we'll consider an `add` function as a function that performs a sum of two numbers:

```csharp
 Func<int, int, int> add = (value, value2) => value + value2;
```

With the application of the `PartialApply` function is created a new function as return, this function needs the last parameter of the sum and returns the result of this operation.

```csharp
Func<int, int, int> add = 
    (value, value2) => value + value2;

Func<int, int> addPartial = PartialApplication.PartialApply(add, 2);
int partialResult = addPartial(3);
```

The major difference between Currying and Partial application is the fact that, when the partial application is used is also necessary inform at least one parameter to apply to the target function.

Other interesting fact about this operation in particular is its returns. Partial Application creates a new function just as Currying does, but this time, the created function must receive all remaining parameters.

The fundamentals about Partial Application and another examples can be find in [Fundamentals > Currying and Partial Application](https://github.com/gabrielschade/tango/tree/379cc4a38ae47796971eb875ec66e7dc053a9081/Concepts/Currying%20and%20Partial%20Application.html).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gabriel-schade-cardoso.gitbook.io/tango/functional/partialapplication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
