memoize
Macros for memoizing functions.
Installation
-
Add the dependency to your
shard.yml
:dependencies: memoize: github: tkshnwesper/memoize
-
Run
shards install
Usage
require "memoize"
Memoize.memoize add_two, NamedTuple(n: Int32), Int32 do
puts "Computed"
n + 2
end
add_two(5) # Prints "Computed" and returns 6
add_two(5) # returns 6
add_two(5) # returns 6
Developing
To generate docs, run
crystal docs --source-refname=<tag>
Contributing
- Fork it (https://github.com/tkshnwesper/memoize/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- tkshnwesper - creator and maintainer