RecursiveJS - an educational library
The functions implemented here are naive implementations that serve absolutely no use in production code. Even more, JavaScript doesn't have yet PTC and TCO available in all major browsers, so a recursive looping approach is not scalable. This library is not meant to be used, but to be read and tried out. It shows how beautiful and powerful recursion is, and how good is JavaScript at showing that.
Almost every looping mechanism implemented here is either self recursive or it uses another function from the same library. Spread is used for pattern matching or array destructuring. Also, we get the function's arity with function.prototype.length etc.
How to use: clone the repo and run node tests/tests.js
.
You'll find implementations of built in methods (like map, filter, reduce), standard utils library methods (like curry, compose, deepClone), a selection of sorting algorithms, path finding algorithms, tree traversal and more. See the full list of modules below.
Enjoy!
List of modules:
- TSP - Travelling salesman problem
- a-star - A* search algorithm
- adjust - ramda docs
- all-anagrams - finds all character permutations in a given string
- all-pass - ramda docs
- all-permutations - finds all permutations of a given array
- all-split-groups - finds all possible ways in which you can split a string
- any-pass - ramda docs
- aperture - ramda docs
- apply-spec - ramda docs
- apply-to - ramda docs
- assoc-path ramda docs
- assoc - ramda docs
- bisect-search - Binary Search algorithm
- bubble-sort-by - bubble sort with custom compare function
- bubble-sort Bubble sort algorithm
- build-trie - utility for building a trie Trie
- cocktail-sort - Cocktail shaker sort
- compose-p - promise composition utility
- compose - simple function composition utility
- concat - standard concat utility
- construct - ramda docs
- converge - ramda docs
- count-by - ramda docs
- count-sort - Counting sort algorithm
- create-store - naive implementation of a redux-like store
- curry - utility for currying
- cycle-sort - Cycle sort algorithm
- deep-clone - utility for deep cloning
- deep-flat - flattens arrays with any level of nesting
- deep-freeze - implements Object.freeze in depth
- default-to - ramda docs
- dijkstra-shortest-path, dijkstra-shortest-path-v2 - Dijkstra's algorithm
- dissoc - ramda docs
- drop-repeats-with ramda docs
- drop - ramda docs
- eq-by - ramda docs
- equals - ramda docs
- every - implementation of the standard Array.prototype method
- evolve - ramda docs
- fill - creates an array filled with n specified elements
- filter - implementation of the standard Array.prototype method
- find - implementation of the standard Array.prototype method
- floyd-warshall - Floyd-Warshall algorithm
- for-each - implementation of the standard Array.prototype method
- gnome-sort - Gnome sort algorithm
- group-by - ramda docs
- group-with - ramda docs
- heap-sort - Heapsort algorithm
- includes - ramda docs
- inner-join - ramda docs
- insertion-sort - Insertion sort algorithm
- intersection - ramda docs
- intersperse - ramda docs
- invoker - ramda docs
- juxt - ramda docs
- kadane - Kadane's algorithm, maximum subarray sum
- length - implementation of the standard Array.prototype method
- levenshtein-distance - Levenshtein distance algorithm
- linked-list-for-each - iterates through a linked list
- linked-list-from-array - creates a linked list from an array
- linked-list-to-array - creates an array from a linked list
- map-obj-indexed - ramda docs
- map - implementation of the standard Array.prototype method
- memoize - utility for memoizing
- merge-lists - list merge function used in merge-sort
- merge-sort - Merge sort algorithm
- merge-with - ramda docs
- merge - utility that merges two objects
- miller-rabin - Miller-Rabin primality test algorithm
- monkey-sort - Bogosort algorithm
- n-ary - ramda docs
- n-permutations - builds a list of n permutations of items in a given array
- object-entries - implementation of Object.entries
- object-values - implementation of Object.values
- omit - ramda docs
- pancake-sort - Pancake sort algorithm
- partition - ramda docs
- path-or - ramda docs
- path-satisfies - ramda docs
- path - ramda docs
- pick - ramda docs
- pluck - ramda docs
- project - ramda docs
- quick-sort-by - quick sort algorithm with custom predicate
- quick-sort-with - quick sort with custom comparator function
- quick-select - Quickselect algorithm
- quick-sort - Quicksort algorithm
- radix-sort - Radix sort algorithm
- range - ramda docs
- reduce-while - ramda docs
- reduce - implementation of the standard Array.prototype method
- reverse - implementation of the standard Array.prototype method
- rotate-matrix - matrix rotation utility
- selection-sort - Selection sort algorithm
- some - implementation of the standard Array.prototype method
- split-every - ramda docs
- split-when - ramda docs
- str-pad-end - adds padding to the end of a given string
- str-pad-start - adds padding to the start of a given string
- swap - swaps two array elements
- symetric-difference - ramda docs
- take-while - ramda docs
- take - ramda docs
- tap - ramda docs
- tim-sort - Timsort algorithm
- trampoline - trampoline utility
- transduce - ramda docs
- transpose - transposes a given array of arrays
- traverse-tree - tree traversal utility
- uncurry-n - ramda docs
- unfold - ramda docs
- union - ramda docs
- unique-by - ramda docs
- unless - ramda docs
- until - ramda docs
- validate-parens - function that validates proper parenthesizing based on provided custom tokens
- why-bird - a variation on the Y combinator
- xprod - ramda docs
- y-combinator - the famous Y combinator
- zip-obj - ramda docs
- zip - ramda docs