]> gitweb.factorcode.org Git - factor.git/commitdiff
lazy.lists: lfrom-by documentation fix
authorSamuel Tardieu <sam@rfc1149.net>
Tue, 6 Dec 2011 18:09:22 +0000 (19:09 +0100)
committerSamuel Tardieu <sam@rfc1149.net>
Tue, 6 Dec 2011 20:08:16 +0000 (21:08 +0100)
Also add a unit test for lfrom-by.

basis/lists/lazy/lazy-docs.factor
basis/lists/lazy/lazy-tests.factor
basis/lists/lazy/lazy.factor

index 201764bd950d771e847522a6738d4150e978b42f..d3827dd85d40703fb4f50f3fa8367034ea12f4ef 100644 (file)
@@ -108,8 +108,8 @@ HELP: lappend
 { $description "Perform a similar functionality to that of the " { $link append } " word, but in a lazy manner. No evaluation of the list elements occurs initially but a " { $link <lazy-append> } " object is returned which conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required. Successive calls to " { $link cdr } " will iterate through list1, followed by list2." } ;
 
 HELP: lfrom-by
-{ $values { "n" "an integer" } { "quot" { $quotation "( -- n )" } } { "lazy-from-by" "a lazy list of integers" } }
-{ $description "Return an infinite lazy list of values starting from n, with each successive value being the result of applying quot to n." } ;
+{ $values { "n" "an integer" } { "quot" { $quotation "( n -- o )" } } { "lazy-from-by" "a lazy list of integers" } }
+{ $description "Return an infinite lazy list of values starting from n, with each successive value being the result of applying quot to the previous value." } ;
 
 HELP: lfrom
 { $values { "n" "an integer" } { "list" "a lazy list of integers" } }
index 39f92158a68bbff851097c1b6a8f6fe70e2248ed..55d29ddb94de9046979b36ab016a62b8c952e3ab 100644 (file)
@@ -28,6 +28,10 @@ IN: lists.lazy.tests
     3 { 1 2 3 } >list [ + ] with lazy-map list>array
 ] unit-test
 
+[ { 1 2 4 8 16 } ] [
+  5 1 [ 2 * ] lfrom-by ltake list>array
+] unit-test
+
 [ [ ] lmap ] must-infer
 [ [ ] lmap>array ] must-infer
 [ [ drop ] foldr ] must-infer
index b430df4e81b44505c6890db46fb6674960656543..be7b0cf54f96f56489a4e2b9421023160324fb6b 100644 (file)
@@ -189,7 +189,7 @@ M: lazy-append nil? ( lazy-append -- ? )
 
 TUPLE: lazy-from-by n quot ;
 
-C: lfrom-by lazy-from-by
+: lfrom-by ( n quot: ( n -- o ) -- lazy-from-by ) lazy-from-by boa ; inline
 
 : lfrom ( n -- list )
     [ 1 + ] lfrom-by ;