memoize: fix docs and bring unit test back.
parent
55431044f9
commit
bcdedab579
|
@ -26,4 +26,8 @@ HELP: MEMO:
|
|||
{ $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." } ;
|
||||
|
||||
{ define-memoized POSTPONE: MEMO: } related-words
|
||||
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: POSTPONE: MEMO[ } related-words
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: math kernel memoize tools.test parser generalizations
|
||||
prettyprint io.streams.string sequences eval namespaces see ;
|
||||
USING: calendar eval generalizations io.streams.string kernel
|
||||
math math.order memoize namespaces parser prettyprint see
|
||||
sequences threads tools.test tools.time ;
|
||||
IN: memoize.tests
|
||||
|
||||
MEMO: fib ( m -- n )
|
||||
|
@ -22,7 +23,7 @@ MEMO: x ( a b c d e -- f g h i j )
|
|||
|
||||
MEMO: see-test ( a -- b ) reverse ;
|
||||
|
||||
{ "USING: memoize sequences ;\nIN: memoize.tests\nMEMO: see-test ( a -- b ) reverse ;\n" }
|
||||
{ "USING: sequences ;\nIN: memoize.tests\nMEMO: see-test ( a -- b ) reverse ;\n" }
|
||||
[ [ \ see-test see ] with-string-writer ]
|
||||
unit-test
|
||||
|
||||
|
@ -33,3 +34,10 @@ unit-test
|
|||
[ 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue