aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/control/function/memo.lux
blob: 35d2eb2512ef18fa05a88c65b1a0af8b4b7d083f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(.module:
  [library
   [lux (#- if loop)
    ["$" documentation (#+ documentation:)]
    [data
     [text (#+ \n)
      ["%" format (#+ format)]]]
    [macro
     ["." template]]]]
  [\\library
   ["." /]])

(documentation: /.open
  "Memoization where the memoized results can be re-used accross invocations."
  [(open memo)])

(documentation: /.closed
  (format "Memoization confined to a single invocation to the function (not counting any subsequent recursive invocations)."
          \n "Memoized results will be re-used during recursive invocations, but cannot be accessed after the main invocation has ended.")
  [(closed hash memo)])

(documentation: /.none
  (format "No memoization at all."
          \n "This is useful as a test control when measuring the effect of using memoization.")
  [(none hash memo)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..open
             ..closed
             ..none
             ($.default /.memoization)
             ($.default (/.Memo input output))]
            []))