summaryrefslogtreecommitdiff
path: root/public/make-memoize.html
diff options
context:
space:
mode:
Diffstat (limited to 'public/make-memoize.html')
-rw-r--r--public/make-memoize.html15
1 files changed, 8 insertions, 7 deletions
diff --git a/public/make-memoize.html b/public/make-memoize.html
index f67c5c5..6dcc7fc 100644
--- a/public/make-memoize.html
+++ b/public/make-memoize.html
@@ -22,13 +22,13 @@
rest = $(wordlist 2,$(words $1),$1)
# How to use: Define 2 variables (the type you would pass to $(call):
-# `_<var>NAME</var>_main` and `_<var>NAME</var>_hash`. Now, `_<var>NAME</var>_main` is the function getting
-# memoized, and _<var>NAME</var>_hash is a function that hashes the function arguments
+# `_<var>NAME</var>_main` and `_<var>NAME</var>_hash`. Now, `_<var>NAME</var>_main` is the function getting
+# memoized, and _<var>NAME</var>_hash is a function that hashes the function arguments
# into a string suitable for a variable name.
#
# Then, define the final function like:
#
-# &lt;var&gt;NAME&lt;/var&gt; = $(foreach func,&lt;var&gt;NAME&lt;/var&gt;,$(memoized))
+# <var>NAME</var> = $(foreach func,<var>NAME</var>,$(memoized))
_main = $(_$(func)_main)
_hash = __memoized_$(_$(func)_hash)
@@ -40,16 +40,17 @@ rest = $(wordlist 2,$(words $1),$1)
# How to use:
#
-# _&lt;var&gt;NAME&lt;/var&gt;_main = &lt;var&gt;your main function to be memoized&lt;/var&gt;
-# _&lt;var&gt;NAME&lt;/var&gt;_hash = &lt;var&gt;your hash function for parameters&lt;/var&gt;
-# &lt;var&gt;NAME&lt;/var&gt; = $(memoized)
+# _<var>NAME</var>_main = <var>your main function to be memoized</var>
+# _<var>NAME</var>_hash = <var>your hash function for parameters</var>
+# <var>NAME</var> = $(memoized)
#
# The output of your hash function should be a string following
# the same rules that variable names follow.
_main = $(_$0_main)
_hash = __memoized_$(_$0_hash)
-memoized = $(if $($(_hash)),,$(eval $(_hash) := _ $(_main)))$(call rest,$($(_hash)))</code></pre>
+memoized = $(if $($(_hash)),,$(eval $(_hash) := _ $(_main)))$(call rest,$($(_hash)))</pre>
+<p></code></p>
<p>Now, I'm pretty sure that should work, but I have only actually tested the first version.</p>
<h2 id="tldr">TL;DR</h2>
<p>Avoid doing things in Make that would make you lean on complex solutions like an external memoize function.</p>