parent
b667e4ff7e
commit
83d8569197
|
@ -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." } ;
|
{ $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
|
HELP: lfrom-by
|
||||||
{ $values { "n" "an integer" } { "quot" { $quotation "( -- n )" } } { "lazy-from-by" "a lazy list of integers" } }
|
{ $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 n." } ;
|
{ $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
|
HELP: lfrom
|
||||||
{ $values { "n" "an integer" } { "list" "a lazy list of integers" } }
|
{ $values { "n" "an integer" } { "list" "a lazy list of integers" } }
|
||||||
|
|
|
@ -28,6 +28,10 @@ IN: lists.lazy.tests
|
||||||
3 { 1 2 3 } >list [ + ] with lazy-map list>array
|
3 { 1 2 3 } >list [ + ] with lazy-map list>array
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
[ { 1 2 4 8 16 } ] [
|
||||||
|
5 1 [ 2 * ] lfrom-by ltake list>array
|
||||||
|
] unit-test
|
||||||
|
|
||||||
[ [ ] lmap ] must-infer
|
[ [ ] lmap ] must-infer
|
||||||
[ [ ] lmap>array ] must-infer
|
[ [ ] lmap>array ] must-infer
|
||||||
[ [ drop ] foldr ] must-infer
|
[ [ drop ] foldr ] must-infer
|
||||||
|
|
|
@ -189,7 +189,7 @@ M: lazy-append nil? ( lazy-append -- ? )
|
||||||
|
|
||||||
TUPLE: lazy-from-by n quot ;
|
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 )
|
: lfrom ( n -- list )
|
||||||
[ 1 + ] lfrom-by ;
|
[ 1 + ] lfrom-by ;
|
||||||
|
|
Loading…
Reference in New Issue