circular: rename circular-while* to circular-loop, add some docs.
parent
3a48ab4688
commit
410a71f677
|
@ -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." } ;
|
{ $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
|
{ $values
|
||||||
{ "circular" circular }
|
{ "circular" circular }
|
||||||
{ "quot" quotation }
|
{ "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"
|
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
|
"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
|
growing-circular-push
|
||||||
}
|
}
|
||||||
"Iterating over a circular until a stop condition:"
|
"Iterating over a circular until a stop condition:"
|
||||||
{ $subsections circular-while circular-while* } ;
|
{ $subsections circular-while circular-loop } ;
|
||||||
|
|
||||||
ABOUT: "circular"
|
ABOUT: "circular"
|
||||||
|
|
|
@ -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 } ] [
|
[ V{ 1 2 3 1 2 } ] [
|
||||||
{ 1 2 3 } <circular> V{ } [
|
{ 1 2 3 } <circular> V{ } [
|
||||||
[ [ push ] [ length 5 < ] bi ] curry circular-while*
|
[ [ push ] [ length 5 < ] bi ] curry circular-loop
|
||||||
] keep
|
] keep
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ V{ 1 } ] [
|
[ V{ 1 } ] [
|
||||||
{ 1 2 3 } <circular> V{ } [
|
{ 1 2 3 } <circular> V{ } [
|
||||||
[ push f ] curry circular-while*
|
[ push f ] curry circular-loop
|
||||||
] keep
|
] keep
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
|
@ -78,5 +78,5 @@ PRIVATE>
|
||||||
: circular-while ( ... circular quot: ( ... obj -- ... ? ) -- ... )
|
: circular-while ( ... circular quot: ( ... obj -- ... ? ) -- ... )
|
||||||
[ clone ] dip [ <circular-iterator> ] dip (circular-while) ; inline
|
[ 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
|
[ clone ] dip '[ [ first @ ] [ rotate-circular ] bi ] curry loop ; inline
|
||||||
|
|
Loading…
Reference in New Issue