Clojure Data Structures and Algorithms Cookbook
eBook - ePub

Clojure Data Structures and Algorithms Cookbook

  1. 216 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Clojure Data Structures and Algorithms Cookbook

Book details
Book preview
Table of contents
Citations

About This Book

25 recipes to deeply understand and implement advanced algorithms in Clojure

About This Book

  • Explore various advanced algorithms and learn how they are used to address many real-world computing challenges
  • Construct elegant solutions using impressive techniques including zippers, parsing, and pattern matching
  • Solve complex problems by adopting innovative approaches such as logic or asynchronous programming

In Detail

Data-structures and algorithms often cross your path when you compress files, compile programs, access databases, or simply use your favourite text editor. Understanding and implementing them can be daunting. Curious learners and industrial developers can find these complex, especially if they focus on the detailed implementation of these data structures.

Clojure is a highly pragmatic and expressive language with efficient and easy data manipulation capabilities. As such, it is great for implementing these algorithms. By abstracting away a great share of the unnecessary complexity resulting from implementation, Clojure and its contrib libraries will help you address various algorithmic challenges, making your data exploration both profitable and enjoyable.

Through 25 recipes, you'll explore advanced algorithms and data-structures, well served by a sound Clojure implementation.

This book opens with an exploration of alternative uses of the array data-structure, covering LZ77 compression, drawing fractals using Pascal's triangles, simulating a multi-threaded program execution, and implementing a call-stack winding and un-winding operations.

The book elaborates on linked lists, showing you how to construct doubly linked ones, speed up search times over the elements of such structures, use a linked-list as the foundation of a shift-reduce parser, and implement an immutable linked-list using skew binary numbers representation.

After that, the tree data-structure is explored, focusing on building self-balancing Splay Trees, designing a B-Tree backing-up an efficient key-value data-store, constructing an undo capable Rope, and showing how Tries can make for an auto-completing facility.

Next, some optimization and machine learning techniques are discussed, namely for building a co-occurrence-based recommendation engine, using branch-and-bound to optimize integral cost and profit problems, using Dijkstra's algorithm to determine optimal paths and summarizing texts using the LexRank algorithm.

Particular attention is given to logic programming, you will learn to use this to discover interesting relations between social website data, by designing a simple type inferencer for a mini Java-like language, and by building a simple checkers game engine.

Asynchronous programming will be addressed and you will design a concurrent web-crawler, an interactive HTML5 game, and an online taxi booking platform.

Finally, you'll explore advanced cases for higher order functions in Clojure while implementing a recursive descent parser using efficient mutual resucrsion, devising a mini resusable firewall simulator thanks to Clojure 1.7 new tansducers feature or building a simple unification engine with the help of Continuation Passing Style.

What You Will Learn

  • Explore alternative uses of classical data-structures like arrays and linked-lists
  • Discover advanced types of tree data-structures
  • Explore advanced machine learning and optimization techniques
  • Utilise powerful Clojure libraries, such as Instaparse for parsing, core.match for pattern matching, clojure.zip for zippers, and clojure.matrix for matrix operations
  • Learn logic programming through the usage of the library core.logic
  • Master asynchronous programming using the core.async library
  • See the transducers in action while resolving real-world use-cases

Who This Book Is For

If you are an experienced Clojure developer, longing to take your knowledge to the next level by discovering and using advanced algorithms and seeing how they can be applied to real-world problems, then this book is for you.

Style and approach

This book consists of a set of step-by-step recipes, each demonstrating the material covered in action so it is put in context. When necessary, pointers to further resources are provided.

Frequently asked questions

Simply head over to the account section in settings and click on ā€œCancel Subscriptionā€ - itā€™s as simple as that. After you cancel, your membership will stay active for the remainder of the time youā€™ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlegoā€™s features. The only differences are the price and subscription period: With the annual plan youā€™ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, weā€™ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Clojure Data Structures and Algorithms Cookbook by Rafik Naccache in PDF and/or ePUB format, as well as other popular books in Computer Science & Databases. We have over one million books available in our catalogue for you to explore.

Information

Year
2015
ISBN
9781785281457
Edition
1

Clojure Data Structures and Algorithms Cookbook


Table of Contents

Clojure Data Structures and Algorithms Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Getting ready
How to do itā€¦
How it worksā€¦
There's moreā€¦
See also
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Revisiting Arrays
Introduction
Efficiently compressing a byte array
How to do it...
Using Pascal's triangle to draw fractals
How to do it...
Simulating multithreading using time-sharing
How to do it...
Simulating a call stack using arrays
How to do it...
2. Alternative Linked Lists
Building a doubly linked XOR list
How to do itā€¦
Speeding up access to linked list elements
How to do itā€¦
Building a simple shift-reduce parser
How to do itā€¦
Implementing a skew binary random access list
How to do itā€¦
3. Walking Down Forests of Data
Introduction
Building self-balancing, search-efficient splay trees
How to do it...
Designing an efficient key-value store using B-trees
How to do it...
How it worksā€¦
Devising an undo-capable data structure using a rope
How to do it...
Designing an autocomplete system using a trie
How to do it...
4. Making Decisions with the Help of Science
Introduction
Designing a live recommendation engine
How to do it...
Resolving cost and profit optimization problems
How to do it...
Finding optimal paths in a graph
How to do it...
Summarizing texts by extracting the most representative sentences
How to do it...
5. Programming with Logic
Introduction
Querying a social website's data
How to do itā€¦
Designing a type inferencer
How to do itā€¦
Playing a round of checkers
How to do itā€¦
6. Sharing by Communicating
Introduction
Building a tiny web crawler
How to do itā€¦
Designing an HTML5 game
How to do itā€¦
Designing an online taxi-booking engine
How to do itā€¦
7. Transformations as First-class Citizens
Introduction
Building a recursive descent parser using trampoline
How to do itā€¦
Implementing a reusable mini-firewall using transducers
How to do itā€¦
Building a little unification engine with the continuation-passing style
How to do it...
Index

Clojure Data Structures and Algorithms Cookbook

Copyright Ā© 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: August 2015
Production reference: 1140815
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-145-7
www.packtpub.com

Credits

Author
Rafik Naccache
Reviewers
Vitomir Kovanović
Muktabh Mayank
Commissioning Editor
Nadeem N. Bagban
Acquisition Editor
Tushar Gupta
Content Development Editor
Natasha DSouza
Technical Editor
Vivek Pala
Copy Editors
Brandt D'Mello
Neha Vyas
Project Coordinator
Vijay Kushlani
Proofreader
Safis Editing
Indexer
Mariammal Chettiyar
Production Coordinator
Conidon Miranda
Cover Work
Conidon Miranda

About the Author

Rafik Naccache is a Tunisian, who is experienced in software architecture and is an emergent technology enthusiast. He earned his bachelor's degree in computer science engineering from the University of Tunis in 2001. Rafik fell in love with Clojure back in 2012 and has been developing it professionally since 2013. He has occupied various positions in the telecom and banking sectors and has launched a few innovative start-ups on the Internet, in which he was able to deploy Clojure apps. He also founded the Tunisian Clojure enthusiasts community. He contributes to open source projects such as Cryogen (https://github.com/cryogen-project/cryogen/graphs/contributors) and Milestones (https://github.com/automagictools/milestones).

About the Reviewers

Vitomir Kovanović is a PhD student at the School of Informatics in the University of Edinburgh, UK. He received an MSc degree in computer science and software engineering in 2011 and a BSc degree in information systems and business administration in 2009 from the University of Belgrade, Serbia. His research interests include learning analytics, educational data mining, and online education. He is a member of the Society for Learning Analytics Research and the program committees of several conferences and journals in technology-enhanced learning. In his PhD research, he focuses on the use of trace data for understanding the effects of technology on the quality of the social learning process and learning outcomes. To find out more about him, visit http://vitomir.kovanovic.info/.

www.PacktPub.com

Support files, eBooks, discount offers, and more

For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
Support files, eBooks, discount offers, and more
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why Subscribe?

  • Fully searchable across every book published by Packt
  • Copy and paste, print, and bookmark content
  • On demand and accessible via a web browser

Free Access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

Preface

The invention of Lisp by John McCarthy in 1958 is certainly one of the most seminal events in the history of computer science. Originally intended as a way of porting Alonzo Church's lambda calculus theory into the realm of computer programs, Lisp pioneered many original ideas, such as ...

Table of contents

  1. Clojure Data Structures and Algorithms Cookbook