Closed kr5hn4 closed 4 years ago
That's quite good. We can probably drop "subroutine" as in the context of functional programming there's no destinction
On Wed, Apr 25, 2018, 6:51 PM hemanth.hm notifications@github.com wrote:
@hemanth commented on this pull request.
In readme.md https://github.com/hemanth/functional-programming-jargon/pull/181#discussion_r184251921 :
@@ -535,6 +536,19 @@ const randIter = rand() randIter.next() // Each execution gives a random value, expression is evaluated on need.
+## Thunk + +A thunk is another word for a function used to inject an additional calculation into another function (or simply a function that is returned by another function). Thunks are primarily used to delay a calculation until its result is needed, or to insert operations at the beginning or end of the other function.
Sounds better, thanks!
We could use const getBigNumber = () => factorial(1000000); see the comment below.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/hemanth/functional-programming-jargon/pull/181#discussion_r184251921, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB-4O9f0CJK13jmW4-kzjNujT_pAgfJks5tsSgOgaJpZM4TZ__B .
Closing as stale. Reopen if you want to be considered again.
I found this definition which may make a good basis:
https://www.techopedia.com/definition/2818/thunk
We can then add a little explanation: Thunks can be used to delay expensive computation until the values are needed.
I would also avoid side effects in the example.
You can use something like
const getBigNumber = () => factorial(1000000);
To represent something that could take a while to compute
On Sun, Apr 22, 2018, 9:42 PM hemanth.hm notifications@github.com wrote: