# Pure Functions

* **Output of pure function depends only on (1) it's input parameters** and (2) it's internal algorithm.&#x20;
* **Сигнатура чистой функции должна говорить о ней все**. Pure functions signatures are meaningfull.&#x20;
* A pure function has no side effects.&#x20;
* Функции так же являются значениями в FP. В Scala есть функции и методы, и метод может быть конвертирован в функцию при помощи eta expansion-выражения. &#x20;

Преимущества:&#x20;

* Easy to write, easier to combine, easier to test, debug and parallelise.
* Pure functions are idempotent.&#x20;
* Referential transparency
* Memoizable
* Lazy

Приемы и методы:

* **HOF**
* **Generic Functions**
* **By-name** (lazy) **parameters**
* **Multiple parameters groups**
* **Control abstractions**
* **Implicit parameters**
* **Default parameter values**
* **Currying**  - функция с множеством параметров всегда может быть преобразована в серию вызовов функций, каждый из которых принимает единственный аргумент.&#x20;
* **Partially Applied Function** - новая функция, полученная путем связывания некоторых параметров функции со значениями.&#x20;

Статьи:

* [Функции и функциональный подход](http://fprog.ru/2009/issue1/roman-dushkin-functional-approach/)


---

# 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://strctr.gitbook.io/programming/03-paradigms/fp/pure-functions.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.
