Cyclic
Details
- A Cyclic specification may use none, some or all of the xi elements, depending upon the number of available positions. If the number of positions is not a multiple of n, then remaining positions toward the end will be filled with x1, x2, etc.
- Cyclic[{x1,…,xn}][0] returns xn, Cyclic[{x1,…,xn}][-1] returns xn-1, and so forth. In general, Cyclic[{x1,…,xn}][k] returns xMod[k,n,1] for any integer k. »
Examples
open all close allBasic Examples (4)
Obtain the fifth element of a sequence that repeats every three elements:
Cyclic[{a, b, c}][5]Extract element
in a sequence that repeats every three elements:
Cyclic[{a, b, c}][-3]Use cyclically repeating colors for the columns of a grid:
Grid[Table[i * j + 4, {i, 6}, {j, 7}], Background -> {Cyclic[{RGBColor[0.286842, 0.530395, 1.], RGBColor[0.56, 0.7, 0.7], RGBColor[0.532474, 0.388, 0.736579]}]}]Use cyclically repeating colors for the rows of a grid:
Grid[Table[i * j + 4, {i, 6}, {j, 7}], Background -> {{}, Cyclic[{RGBColor[0.286842, 0.530395, 1.], RGBColor[0.56, 0.7, 0.7], RGBColor[0.532474, 0.388, 0.736579]}]}]Scope (4)
Alternate the rows between bold and italic font:
Grid[Array[#1 * #2&, {7, 7}], ItemStyle -> {{}, Cyclic[{Italic, Bold}] }]Combine this with cyclically repeating colors for the columns:
Grid[Array[#1 * #2&, {7, 7}], ItemStyle -> {Cyclic[{RGBColor[1., 0.4, 0.], RGBColor[0.655728, 0.8, 0.], RGBColor[0., 0.742291, 0.873126]}], Cyclic[{Italic, Bold}] }]Specify the colors for the first few columns, then fill in the rest cyclically:
Grid[Table[i * j + 4, {i, 6}, {j, 7}], Background -> {{ColorData[109][4], ColorData[109][5], Cyclic[{RGBColor[1., 0.4, 0.], RGBColor[0.655728, 0.8, 0.], RGBColor[0., 0.742291, 0.873126]}]}}]Extract an element with a very large index:
Cyclic[{a, b, c}][10 ^ 100]Compute elements
,
and
in a sequence:
Table[Cyclic[{a, b, c}][k], {k, 0, -2, -1}]Applications (1)
Properties & Relations (3)
Cyclic[list][1] gives First[list]:
Cyclic[{Red, Green, Blue}][1] === First[{Red, Green, Blue}]Cyclic[list][0] gives Last[list]:
Cyclic[{Red, Green, Blue}][0] === Last[{Red, Green, Blue}]Cyclic[list][k] gives Part[list,Mod[k,Length[list],1]]:
With[{list = {Cyan, Magenta, Yellow, Blue}, k = RandomInteger[{-100, 100}]}, Cyclic[list][k] === list[[Mod[k, Length[list], 1]]]]History
Text
Wolfram Research (2025), Cyclic, Wolfram Language function, https://reference.wolfram.com/language/ref/Cyclic.html.
CMS
Wolfram Language. 2025. "Cyclic." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Cyclic.html.
APA
Wolfram Language. (2025). Cyclic. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Cyclic.html
BibTeX
@misc{reference.wolfram_2026_cyclic, author="Wolfram Research", title="{Cyclic}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/Cyclic.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_cyclic, organization={Wolfram Research}, title={Cyclic}, year={2025}, url={https://reference.wolfram.com/language/ref/Cyclic.html}, note=[Accessed: 12-June-2026]}