https://github.com/bakenezumi/memoz
https://github.com/bakenezumi/memoz
elixir
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bakenezumi/memoz
- Owner: bakenezumi
- License: other
- Created: 2017-07-06T06:32:25.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-06T08:41:06.000Z (almost 9 years ago)
- Last Synced: 2025-10-09T19:51:38.733Z (9 months ago)
- Topics: elixir
- Language: Elixir
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MemoZ
MemoZ run recursive while memoizing anonymous function.
MemoLoop is a macro to simplify it.
## Installation
Adding `memoz` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:memoz, "~> 0.2.0"}]
end
```
## Example
function version
```elixir
MemoZ.init(fn f -> fn
0 -> 0
1 -> 1
x -> f.(x-1) + f.(x-2)
end end).(100) #=> 354224848179261915075
```
macro version
```elixir
import MemoLoop
loop 100 do
0 -> 0
1 -> 1
x -> recur(x-1) + recur(x-2)
end #=> 354224848179261915075
```