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.
The Mikado Method by Ola Ellnestam Daniel Brolund(22436)
Hello! Python by Anthony Briggs(21626)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(20184)
Dependency Injection in .NET by Mark Seemann(19563)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(19311)
Kotlin in Action by Dmitry Jemerov(19237)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(18777)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(17578)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(16967)
Grails in Action by Glen Smith Peter Ledbrook(16730)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(14223)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(12199)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(10923)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10598)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(10030)
Hit Refresh by Satya Nadella(9118)
The Kubernetes Operator Framework Book by Michael Dame(8539)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8365)
Robo-Advisor with Python by Aki Ranin(8307)