Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/costajob/fibonacci-ex
Fibonacci computator in the Elixir language
https://github.com/costajob/fibonacci-ex
Last synced: 13 days ago
JSON representation
Fibonacci computator in the Elixir language
- Host: GitHub
- URL: https://github.com/costajob/fibonacci-ex
- Owner: costajob
- Created: 2015-02-18T13:23:05.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-02-19T15:24:41.000Z (over 9 years ago)
- Last Synced: 2023-08-12T17:32:58.796Z (about 1 year ago)
- Language: Elixir
- Size: 141 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fibonacci computator in Elixir
A simple module to perform Fibonacci computation in the [Elixir language](http://elixir-lang.org/).## Motivation
I am not a great fan of mathematic, but the [sequence of Fibonacci](http://en.wikipedia.org/wiki/Fibonacci_number) is a good work horse to stress computation via recursive logic with any programming language.## No tail-recursion
This version does not attempt to perform tail-recursion, which indeed is optimized by some (BEAM) virtual machines (for an elegant solution [look here](https://searchcode.com/codesearch/view/2719356/)).
Instead it relies on multiprocessing and memoization by using the Agent and Task abstractions in the Elixir base library.## Cache VS Uncache
Computation without cache starts struggling when reaching numbers near 30 (MacBook Pro i7 2.2Ghz 8GB).
Memoized version is a blaze, but trades speed for memory consumption.## API
The use of the library is pretty straightforward:1..10 |> Enum.map &Fibonacci.of/1
For the cached version remember to initialize the Agent:
Fibonacci.cache_start
Fibonacci.of 10000