circular: rename circular-while* to circular-loop, add some docs.

db4
John Benediktsson 2013-09-06 10:16:20 -07:00
parent 3a48ab4688
commit 410a71f677
3 changed files with 7 additions and 6 deletions

View File

@ -55,12 +55,13 @@ HELP: circular-while
}
{ $description "Calls " { $snippet "quot" } " on each element of the sequence until each call yields " { $link f } " in succession." } ;
HELP: circular-while*
HELP: circular-loop
{ $values
{ "circular" circular }
{ "quot" quotation }
}
{ $description "Calls " { $snippet "quot" } " on each element of the sequence until one call yields " { $link f } "." } ;
{ $description "Calls " { $snippet "quot" } " on each element of the sequence until one call yields " { $link f } "." }
{ $notes "This rotates the " { $link circular } " object after each call, so the next element to be applied will always be the first element." } ;
ARTICLE: "circular" "Circular sequences"
"The " { $vocab-link "circular" } " vocabulary implements the " { $link "sequence-protocol" } " to allow an arbitrary start index and wrap-around indexing." $nl
@ -81,6 +82,6 @@ ARTICLE: "circular" "Circular sequences"
growing-circular-push
}
"Iterating over a circular until a stop condition:"
{ $subsections circular-while circular-while* } ;
{ $subsections circular-while circular-loop } ;
ABOUT: "circular"

View File

@ -65,12 +65,12 @@ CONSTANT: test-sequence2 { t f t t f f t t t f f f }
[ V{ 1 2 3 1 2 } ] [
{ 1 2 3 } <circular> V{ } [
[ [ push ] [ length 5 < ] bi ] curry circular-while*
[ [ push ] [ length 5 < ] bi ] curry circular-loop
] keep
] unit-test
[ V{ 1 } ] [
{ 1 2 3 } <circular> V{ } [
[ push f ] curry circular-while*
[ push f ] curry circular-loop
] keep
] unit-test

View File

@ -78,5 +78,5 @@ PRIVATE>
: circular-while ( ... circular quot: ( ... obj -- ... ? ) -- ... )
[ clone ] dip [ <circular-iterator> ] dip (circular-while) ; inline
: circular-while* ( ... circular quot: ( ... obj -- ... ? ) -- ... )
: circular-loop ( ... circular quot: ( ... obj -- ... ? ) -- ... )
[ clone ] dip '[ [ first @ ] [ rotate-circular ] bi ] curry loop ; inline