Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
pp:2026:scala:l02 [2026/03/05 08:06] ldaniel |
pp:2026:scala:l02 [2026/03/06 13:09] (current) ana.ailiesei |
||
|---|---|---|---|
| Line 79: | Line 79: | ||
| </code> | </code> | ||
| - | **2.3.5** Write a function ''sum'' which takes values start, end and computes the sum of numbers between start and end. | + | **2.3.5** Write a function ''sum'' which takes values start, stop and computes the sum of numbers between start and stop. |
| Use the curry function ''foldWith'' defined before. | Use the curry function ''foldWith'' defined before. | ||
| <code scala> | <code scala> | ||
| Line 115: | Line 115: | ||
| As a result, by executing intense computation on this branch, we would delay other functionalities or would lock into a specific task instead of scheduling. | As a result, by executing intense computation on this branch, we would delay other functionalities or would lock into a specific task instead of scheduling. | ||
| - | To solve this limitation, programmers have created ways ('''functional closures''') in which the main thread injects all the needed parameters to functions and then passes them to other threads, from where they can be unpacked and run. | + | To solve this limitation, programmers have created ways (''functional closures'') in which the main thread injects all the needed parameters to functions and then passes them to other threads, from where they can be unpacked and run. |
| - | Such an implementation for functional closures is represented by '''zero-parameter lambdas''' where the evaluation is delayed by currying such a function over our method: | + | For a better understanding, compare the implementation of ''curry_for_thread'' with the one for ''apply'' at 2.1.1. |
| + | |||
| + | Such an implementation for functional closures is represented by ''zero-parameter lambdas'' where the evaluation is delayed by currying such a function over our method: | ||
| <code scala> | <code scala> | ||