{ $values { "word" "a new word to define" } { "definition" "a word definition" } }
{ $description "Defines the given word at parse time as one which memoizes its output given a particular input. The stack effect is mandatory." } ;
-HELP: MEMO[
-{ $syntax "MEMO[ elements... ]" }
-{ $description "Defines the given literal quotation as one which memoizes its outputs given a particular input." } ;
-
{ define-memoized POSTPONE: MEMO: } related-words
! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
-USING: calendar math math.order kernel memoize tools.test parser
-generalizations prettyprint io.streams.string sequences eval
-namespaces see threads tools.time ;
+USING: math kernel memoize tools.test parser generalizations
+prettyprint io.streams.string sequences eval namespaces see ;
IN: memoize.tests
MEMO: fib ( m -- n )
[ sq ] ( a -- b ) memoize-quot "q" set
[ 9 ] [ 3 "q" get call ] unit-test
-
-[ t ] [
- { 1/8 1/8 1/8 1/8 1/16 1/16 1/16 }
- [ MEMO[ seconds sleep ] each ] benchmark
- 0.18e9 0.25e9 between?
-] unit-test
! See http://factorcode.org/license.txt for BSD license.
USING: kernel hashtables sequences sequences.private arrays
words namespaces make parser effects.parser math assocs effects
-definitions quotations summary accessors fry hashtables.identity
-stack-checker ;
+definitions quotations summary accessors fry hashtables.identity ;
IN: memoize
<PRIVATE
[ stack-effect in>> packer call ] [ "memoize" word-prop delete-at ] bi ;
\ invalidate-memoized t "no-compile" set-word-prop
-
-SYNTAX: MEMO[ parse-quotation dup infer memoize-quot suffix! ;
--- /dev/null
+
+USING: help.markup help.syntax memoize.syntax ;
+
+HELP: MEMO[
+{ $syntax "MEMO[ elements... ]" }
+{ $description "Defines the given literal quotation as one which memoizes its outputs given a particular input." } ;
--- /dev/null
+USING: calendar math.order memoize.syntax sequences threads
+tools.test tools.time ;
+
+IN: memoize.syntax.tests
+
+[ t ] [
+ { 1/8 1/8 1/8 1/8 1/16 1/16 1/16 }
+ [ MEMO[ seconds sleep ] each ] benchmark
+ 0.18e9 0.25e9 between?
+] unit-test
--- /dev/null
+USING: kernel memoize parser sequences stack-checker ;
+
+IN: memoize.syntax
+
+SYNTAX: MEMO[ parse-quotation dup infer memoize-quot suffix! ;
+