Functional Programming For Dummies by John Paul Mueller
Author:John Paul Mueller
Language: eng
Format: epub
ISBN: 9781119527510
Publisher: Wiley
Published: 2019-04-02T00:00:00+00:00
Sorting data with Haskell
Haskell provides a wide variety of sorting mechanisms, such that you probably won’t have to resort to doing anything of a custom nature unless your data is unique and your requirements are unusual. However, getting the native functionality that's found in existing libraries can prove a little daunting at times unless you think the process through first. To start, you need a list that’s a little more complex than others used in this chapter: original = [(1, "Hello"), (4, "Yellow"), (5, "Goodbye"), (2, "Yes"), (3, "No")]. Use the following code to perform a basic sort:
import Data.List as Dl
sort original
The output is based on the first member of each tuple: [(1,"Hello"),(2,"Yes"),(3,"No"),(4,"Yellow"),(5,"Goodbye")]. If you want to perform a reverse sort, you can use the following call instead:
(reverse . sort) original
Download
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.
Deep Learning with Python by François Chollet(12702)
Hello! Python by Anthony Briggs(10008)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9876)
The Mikado Method by Ola Ellnestam Daniel Brolund(9871)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(9798)
Dependency Injection in .NET by Mark Seemann(9421)
Hit Refresh by Satya Nadella(8871)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8386)
The Kubernetes Operator Framework Book by Michael Dame(7989)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7837)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7808)
Exploring Deepfakes by Bryan Lyon and Matt Tora(7787)
Grails in Action by Glen Smith Peter Ledbrook(7772)
Practical Computer Architecture with Python and ARM by Alan Clements(7730)
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(7694)
Robo-Advisor with Python by Aki Ranin(7680)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7654)
Building Low Latency Applications with C++ by Sourav Ghosh(7575)
Svelte with Test-Driven Development by Daniel Irvine(7562)
