Learn Enough Ruby to Be Dangerous: Write Programs, Publish Gems, and Develop Sinatra Web Apps with Ruby by Michael Hartl
Author:Michael Hartl [Michael Hartl]
Language: eng
Format: epub, pdf, mobi
Publisher: Addison-Wesley Professional
Published: 2022-06-17T00:00:00+00:00
Click here to view code image
states.reduce({}) { |lengths, state| lengths.merge({state => state.length}) }
See the documentation on merge for more information.)
As required, the result is the same as the imperative solution:
Click here to view code image
$ ruby functional.rb . . . {"Kansas"=>6, "Nebraska"=>8, "North Dakota"=>12, "South Dakota"=>12} {"Kansas"=>6, "Nebraska"=>8, "North Dakota"=>12, "South Dakota"=>12}
Comparing the imperative and functional solutions in Listing 6.9, the advantages of reduce are not as clear as they were in the case of map and select. Indeed, a good argument can be made that the imperative solution is clearer.
Which method to use is a matter of taste. Iâve found that the more you program functionally, the more you want to do it, and thereâs a strange sort of pleasure in using reduce to solve a problem in a single (logical) line. Itâs also worth noting that reduce is a common technique among more advanced programmers, and among other things plays a key role in an important technique (called MapReduce) for dealing efficiently with large datasets.
Download
Learn Enough Ruby to Be Dangerous: Write Programs, Publish Gems, and Develop Sinatra Web Apps with Ruby by Michael Hartl.pdf
Learn Enough Ruby to Be Dangerous: Write Programs, Publish Gems, and Develop Sinatra Web Apps with Ruby by Michael Hartl.mobi
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Ada | Ajax |
Assembly Language Programming | Borland Delphi |
C & C++ | C# |
CSS | Compiler Design |
Compilers | DHTML |
Debugging | Delphi |
Fortran | Java |
Lisp | Perl |
Prolog | Python |
RPG | Ruby |
Swift | Visual Basic |
XHTML | XML |
XSL |
Hello! Python by Anthony Briggs(9873)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9763)
The Mikado Method by Ola Ellnestam Daniel Brolund(9754)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8264)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7755)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7748)
Grails in Action by Glen Smith Peter Ledbrook(7673)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7523)
Windows APT Warfare by Sheng-Hao Ma(6525)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6385)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(6271)
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition by Marcos Romero & Brenden Sewell(6146)
Kotlin in Action by Dmitry Jemerov(5025)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4304)
Functional Programming in JavaScript by Mantyla Dan(4025)
Solidity Programming Essentials by Ritesh Modi(3857)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3629)
Unity 3D Game Development by Anthony Davis & Travis Baptiste & Russell Craig & Ryan Stunkel(3580)
The Ultimate iOS Interview Playbook by Avi Tsadok(3548)
