Skip to content

Commit 60011d8

Browse files
committed
Translate "Partial application" part into russian
1 parent 114e30e commit 60011d8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

_ru/tour/multiple-parameter-lists.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,20 @@ numbers.foldRight(0)(_+_) // Форма с каррированием
7878
def execute(arg: Int)(implicit ec: ExecutionContext) = ???
7979
```
8080

81+
#### Частичное применение
82+
Когда метод вызывается с меньшим количеством списков параметров, то результатом будет функция,
83+
которая принимает в качестве параметров недостающие списки. Это официально известно как
84+
[частичное применение](https://ru.wikipedia.org/wiki/%D0%A7%D0%B0%D1%81%D1%82%D0%B8%D1%87%D0%BD%D0%BE%D0%B5_%D0%BF%D1%80%D0%B8%D0%BC%D0%B5%D0%BD%D0%B5%D0%BD%D0%B8%D0%B5).
85+
86+
Например,
87+
88+
```tut
89+
val numbers = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
90+
val numberFunc = numbers.foldLeft(List[Int]()) _
91+
92+
val squares = numberFunc((xs, x) => xs :+ x*x)
93+
print(squares) // List(1, 4, 9, 16, 25, 36, 49, 64, 81, 100)
94+
95+
val cubes = numberFunc((xs, x) => xs :+ x*x*x)
96+
print(cubes) // List(1, 8, 27, 64, 125, 216, 343, 512, 729, 1000)
97+
```

0 commit comments

Comments
 (0)