Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Many books about algorithms and data structures are coded by imperative languages. Is there any book that can show functional programming languages can do the same thing or do them better?

In particular I am interested in sorting, searching, data structures and graph.

share|improve this question
Well unfortunately I don't have any books for you, but some things you could look into further are that many functional programs encourage laziness and this can lead to lazy sorting algorithms where only what is required to be sorted is. It can also lead to easier manipulation of infinite tree/graphs because you the programmer can often just treat them as you'd treat a finite graph. –  WuHoUnited Mar 15 '12 at 2:05
add comment

closed as not constructive by MichaelT, gnat, GlenH7, Rein Henrichs, Bart van Ingen Schenau May 3 '13 at 8:08

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers

up vote 2 down vote accepted

If you're interested in purely functional data structures (which naturally go hand-in-hand with algorithms) you should check out Okasaki's Purely Functional Data Structures. It's in ML (with examples in Haskell as well) rather than Lisp, but it is still a very good resource for purely functional programming.

share|improve this answer
add comment

I hope I did not understand the question wrong since I saw no suggestion for this book.

In my university we have a course that teaches paradigms of programming languages, they involve prolog, and lisp basically since we already cover Pascal, C, and Java on previous semesters.

The adopted book is available online for free: http://www.gigamonkeys.com/book/

I used this book most for reference, but I think to be a good one. While I as an assistant in this course we suggested the creation of a "LispUnit" a simple program so that students could test their own assignments. The code is available there online, and it was a very interesting experience.

Few students ended up learning how to test using Lisp actually.

On one of the assignments we proposed we emphasized as well how the idea of building from very simple blocks and reusing them on functional programming was more natural than in Java or C. We used few basic natural functions such as +, -, etc. Gave them the successor operation and they ended up creating many of the natural functions on Lisp. I think this is a simple, yet powerful way to mix mathematical concepts, specially since this is covered on Discrete Mathematics for Computer sciences degrees. We did not use LISP for anything like a real application thou, but I believe this book to provide better examples such as the test framework.

Hope this helps.

share|improve this answer
add comment

A very thorough introduction to the core foundations of computer science, e.g.

  • some data structures and algorithms,
  • what's under the hood of a functional programming language,
  • how to use abstraction and modularity

is the classic book Structure and Interpretation of Computer Programs (SICP), which uses the language Scheme.

The book is also online at MIT, where they are using it heavily in teaching.

share|improve this answer
add comment

A Haskell-based book:

Algorithms: A Functional Programming Approach, by Fethi Rabhi and Guy Lapalme

ISBN 0-201-59604-0


Also, this one seems like a nice little paper. Available online, too:

Jamie Snape, Loopless Functional Algorithms,

Master's thesis, Computing Laboratory, University of Oxford, 2005, advised by Richard S. Bird


share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.