All Projects → mmottl → Pure Fun

mmottl / Pure Fun

Licence: other
Purely functional data structures for OCaml, translated from Chris Okasaki's book "Purely Functional Data Structures"

Programming Languages

ocaml
1615 projects

Projects that are alternatives of or similar to Pure Fun

Algorithms
Here is the my solutions for problems in {leetcode, hackerrank, geeksforgeeks}
Stars: ✭ 36 (-65.05%)
Mutual labels:  datastructures
Datastructures
🚀 Implementation of core data structures for R
Stars: ✭ 64 (-37.86%)
Mutual labels:  datastructures
Data Structures And Algorithms
Python implementation of common algorithms and data structures interview questions
Stars: ✭ 84 (-18.45%)
Mutual labels:  datastructures
Data Structure And Algorithms
A complete and efficient guide for Data Structure and Algorithms.
Stars: ✭ 48 (-53.4%)
Mutual labels:  datastructures
String Interner
A data structure to efficiently intern, cache and restore strings.
Stars: ✭ 60 (-41.75%)
Mutual labels:  datastructures
Algorithms
University course material for Algorithms and Data Structures in Java, with a particular emphasis on software testing. Includes exercises, with solutions.
Stars: ✭ 66 (-35.92%)
Mutual labels:  datastructures
Data Structures
Walk-through and implementation of various data structures.
Stars: ✭ 15 (-85.44%)
Mutual labels:  datastructures
Repository
个人学习知识库涉及到数据仓库建模、实时计算、大数据、Java、算法等。
Stars: ✭ 92 (-10.68%)
Mutual labels:  datastructures
Complete Placement Preparation
This repository consists of all the material required for cracking the coding rounds and technical interviews during placements.
Stars: ✭ 1,114 (+981.55%)
Mutual labels:  datastructures
C
Collection of various algorithms in mathematics, machine learning, computer science, physics, etc implemented in C for educational purposes.
Stars: ✭ 11,897 (+11450.49%)
Mutual labels:  datastructures
Competitive Programming
Repository of all my submissions to some competitive programming website (Online Judges), as well as, the implementation of some data structures and algorithms.
Stars: ✭ 53 (-48.54%)
Mutual labels:  datastructures
Awesome Java Leetcode
👑 LeetCode of algorithms with java solution(updating).
Stars: ✭ 8,297 (+7955.34%)
Mutual labels:  datastructures
Coding Cheat Sheets
Various cheat sheets on CS stuff
Stars: ✭ 1,172 (+1037.86%)
Mutual labels:  datastructures
Math Advanced Data Structures And Algorithms
Math, Advanced Data Structures & Algorithms - Please check before use
Stars: ✭ 40 (-61.17%)
Mutual labels:  datastructures
Cracking The Coding Interview
Tests, Questions and Solutions from Cracking the Coding Interview
Stars: ✭ 91 (-11.65%)
Mutual labels:  datastructures
Fundamentals Of Python Data Structures
《数据结构(Python语言描述)》"Fundamentals of Python:Data Structures" 电子书和配套代码
Stars: ✭ 30 (-70.87%)
Mutual labels:  datastructures
Roaringbitmap
Roaring Bitmap in Cython
Stars: ✭ 64 (-37.86%)
Mutual labels:  datastructures
Deque
Fast bounded deque using two rotating lists.
Stars: ✭ 97 (-5.83%)
Mutual labels:  datastructures
Datascience
It consists of examples, assignments discussed in data science course taken at algorithmica.
Stars: ✭ 92 (-10.68%)
Mutual labels:  datastructures
Adaptive Radix Tree
A fast and space efficient Radix tree in Java
Stars: ✭ 76 (-26.21%)
Mutual labels:  datastructures

Pure-Fun - Purely Functional Data Structures for OCaml

What is Pure-Fun?

The files in this project contain an SML-to-OCaml translation of source examples taken from the following book:

Purely Functional Data Structures
Chris Okasaki
Cambridge University Press, 1998
Copyright (c) 1998 Cambridge University Press

Notes Regarding the Translation

The first nine chapters are translated now. There are two further chapters, whose implementation requires polymorphic recursion. This feature was not available in OCaml for a while, which is why they have not been translated yet. Feel free to contribute them!

This translation is as close as possible to the original code, but some deviations from the original were necessary. The following rules / differences to the original sources exist:

No base module

Since there is hardly anything indispensable in the base module, its relevant contents was copied into each module. This allows for easier testing, because the modules do not depend on others.

Syntax

Names are created by the following rules:

  • Module types are written in capitals. If they consist of more than a word, an underscore (_) is placed between the words.

  • Names of exceptions follow the same rule as modules types.

  • Module implementations have to start with a capital letter, the rest of the name is lowercase - except if it consists of more than one word. In this case the first letter of the following word is uppercase. There is no underscore between words.

Currying of function parameters

Currying is not used anywhere in the original source. The translation curries parameters where it makes sense. Tuples that represent a named type (e.g. some data structure) are not curried in functions that are hidden by a signature restriction. This seems to aid comprehension. Functions offered via the module interface (signature) do not reveal such implementation details (i.e. the concrete type) anyway.

Superfluous bindings

If a parameter is never used in a following expression, it is not bound to any name. The underscore (_) will hold its place.

Lazy evaluation

The syntax for lazy evaluation used to implement the data structures and algorithms that require them is quite different from the original. The lazy type is used to specify data structures that need lazy evaluation. OCaml recently also introduced pattern matching on lazy values, which is used throughout.

To make the syntax at least a bit more similar to the original, we have also introduced the prefix operator (!$), which stands for force - it forces evaluation of a lazy expression. To make an expression lazy, the OCaml-keyword lazy is used.

There is a test function at the end of the translation of chapter 4, the chapter in which lazy evaluation and streams (= lazy lists) are introduced. Uncomment it to see how lazy evaluation works.

Notes on Efficiency

Because the data structures are purely functional, they profit a lot from garbage collector settings. In case you find that some of them are not efficient enough, you might want to raise the memory overhead parameter of the garbage collector. Performance is in general excellent.

Contact Information and Contributing

Please submit bugs reports, feature requests, contributions and similar to the GitHub issue tracker.

Up-to-date information is available at: https://mmottl.github.io/pure-fun

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].