Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Lambdas and Streams
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework
this week in the
Java in General
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Liutauras Vilda
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Devaka Cooray
Paul Clapham
Saloon Keepers:
Scott Selikoff
Tim Holloway
Piet Souris
Mikalai Zaikin
Frits Walraven
Bartenders:
Stephan van Hulst
Carey Brown
Forum:
Lambdas and Streams
inversion of control in FP
Jignesh Patel
Ranch Hand
Posts: 691
I like...
posted 2 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How we can experience inversion of control in context of functional programming?
Michał Płachta
Author
Posts: 31
5
posted 2 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This is a hot topic in this book
In short, you invert the control by passing a function to a function. For example, if you are sorting a list of Book values, you can:
val books: List[Book] = ... books.sortBy(sortFunction)
where sortFunction is a function that takes a Book and returns it's "rating". sortBy doesn't know what the sortFunction does, it just uses it.
Jignesh Patel
Ranch Hand
Posts: 691
I like...
posted 2 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Michał Płachta wrote:
In short, you invert the control by passing a function to a function.
Interesting thinking!!! Another good reason to purchase the book. As this concept requires a bit of study with the clear head.
Stephan van Hulst
Bartender
Posts: 15737
368
posted 2 years ago
1
Number of slices to send:
Optional 'thank-you' note:
Send
I think you have to worry less about IoC in languages that are purely functional, because it comes natural: A pure function always requires you to inject data or dependencies as function parameters. There is no global state.
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Dazed and Confused
Functional Programming to Venkat
Functional Design and Architecture - CAP
How to focus in learning technologies?
New forum for general Functional Programming questions
More...