[{"data":1,"prerenderedAt":721},["ShallowReactive",2],{"navigation_docs":3,"-core-features-loops":198,"-core-features-loops-surround":716},[4,30,81,118,147,171,184],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":6},"Getting Started",false,"/getting-started","1.getting-started",[10,15,20,25],{"title":11,"path":12,"stem":13,"icon":14},"Introduction","/getting-started/introduction","1.getting-started/2.introduction","i-lucide-house",{"title":16,"path":17,"stem":18,"icon":19},"Installation","/getting-started/installation","1.getting-started/3.installation","i-lucide-download",{"title":21,"path":22,"stem":23,"icon":24},"Quick start","/getting-started/quickstart","1.getting-started/4.quickstart","i-lucide-code-xml",{"title":26,"path":27,"stem":28,"icon":29},"Troubleshooting","/getting-started/troubleshooting","1.getting-started/5.troubleshooting","i-lucide-wrench",{"title":31,"icon":6,"path":32,"stem":33,"children":34,"page":6},"Core Features","/core-features","2.core-features",[35,39,43,48,52,56,60,64,68,73,77],{"title":36,"path":37,"stem":38,"icon":24},"Main function","/core-features/main-function","2.core-features/1.main-function",{"title":40,"path":41,"stem":42,"icon":24},"Variables","/core-features/variables","2.core-features/2.variables",{"title":44,"path":45,"stem":46,"icon":47},"Comment","/core-features/comment","2.core-features/3.comment","i-lucide-hash",{"title":49,"path":50,"stem":51,"icon":24},"Conditionals","/core-features/conditionals","2.core-features/4.conditionals",{"title":53,"path":54,"stem":55,"icon":24},"Loops","/core-features/loops","2.core-features/5.loops",{"title":57,"path":58,"stem":59,"icon":24},"Functions","/core-features/functions","2.core-features/6.functions",{"title":61,"path":62,"stem":63,"icon":24},"Pointers","/core-features/pointers","2.core-features/7.pointers",{"title":65,"path":66,"stem":67,"icon":24},"Data types","/core-features/datatypes","2.core-features/8.datatypes",{"title":69,"path":70,"stem":71,"icon":72},"Operators","/core-features/operators","2.core-features/9.operators","i-lucide-percent",{"title":74,"path":75,"stem":76,"icon":24},"Literals","/core-features/a.literals","2.core-features/a.literals",{"title":78,"path":79,"stem":80,"icon":24},"Keywords","/core-features/b.keywords","2.core-features/b.keywords",{"title":82,"icon":6,"path":83,"stem":84,"children":85,"page":6},"Features","/features","3.features",[86,90,94,98,102,106,110,114],{"title":87,"path":88,"stem":89,"icon":24},"Const","/features/const","3.features/1.const",{"title":91,"path":92,"stem":93,"icon":24},"Define","/features/define","3.features/2.define",{"title":95,"path":96,"stem":97,"icon":24},"Enum","/features/enum","3.features/3.enum",{"title":99,"path":100,"stem":101,"icon":24},"Union","/features/union","3.features/4.union",{"title":103,"path":104,"stem":105,"icon":24},"Overloading","/features/overloading","3.features/5.overloading",{"title":107,"path":108,"stem":109,"icon":24},"Lambda","/features/lambda","3.features/6.lambda",{"title":111,"path":112,"stem":113,"icon":24},"Callback","/features/callback","3.features/7.callback",{"title":115,"path":116,"stem":117,"icon":24},"Auto","/features/auto","3.features/8.auto",{"title":119,"icon":6,"path":120,"stem":121,"children":122,"page":6},"Advance Features","/advance","4.advance",[123,127,131,135,139,143],{"title":124,"path":125,"stem":126,"icon":24},"Generic Type","/advance/generic-type","4.advance/1.generic-type",{"title":128,"path":129,"stem":130,"icon":24},"Errors","/advance/error","4.advance/2.error",{"title":132,"path":133,"stem":134,"icon":24},"Annotation","/advance/annotation","4.advance/3.annotation",{"title":136,"path":137,"stem":138,"icon":24},"Variadic Function","/advance/variadic-func","4.advance/4.variadic-func",{"title":140,"path":141,"stem":142,"icon":24},"Module","/advance/module-interface","4.advance/5.module-interface",{"title":144,"path":145,"stem":146,"icon":24},"Operator Overloading","/advance/operator-overloading","4.advance/6.operator-overloading",{"title":148,"icon":6,"path":149,"stem":150,"children":151,"page":6},"Struct","/struct","5.struct",[152,155,159,163,167],{"title":148,"path":153,"stem":154,"icon":24},"/struct/struct","5.struct/1.struct",{"title":156,"path":157,"stem":158,"icon":24},"Methods","/struct/methods","5.struct/2.methods",{"title":160,"path":161,"stem":162,"icon":24},"Init/Deinit","/struct/init-deinit","5.struct/3.init-deinit",{"title":164,"path":165,"stem":166,"icon":24},"Encapsulation","/struct/encapsulation","5.struct/4.encapsulation",{"title":168,"path":169,"stem":170,"icon":24},"Static","/struct/static","5.struct/5.static",{"title":172,"icon":6,"path":173,"stem":174,"children":175,"page":6},"Data Structures","/data-structure","6.data-structure",[176,180],{"title":177,"path":178,"stem":179,"icon":24},"Array","/data-structure/array","6.data-structure/array",{"title":181,"path":182,"stem":183,"icon":24},"Structural Type","/data-structure/strutural-type","6.data-structure/strutural-type",{"title":185,"icon":6,"path":186,"stem":187,"children":188,"page":6},"Standard Libraries","/stdlib","7.stdlib",[189,194],{"title":190,"path":191,"stem":192,"icon":193},"stdlib","/stdlib/stdlib","7.stdlib/stdlib","i-lucide-library-big",{"title":195,"path":196,"stem":197,"icon":24},"syscall","/stdlib/syscall","7.stdlib/syscall",{"id":199,"title":53,"body":200,"description":709,"extension":710,"links":711,"meta":712,"navigation":713,"path":54,"seo":714,"stem":55,"__hash__":715},"docs/2.core-features/5.loops.md",{"type":201,"value":202,"toc":704},"minimark",[203,207,234,239,242,284,290,339,348,352,356,365,396,400,479,497,501,506,526,561,565,619,625,685,693,700],[204,205,206],"p",{},"This page shows you how to control the flow of your code to reapeatly perform a task by using different kind of loops in Cambo.",[208,209,210,213],"blockquote",{},[204,211,212],{},"There are 3 types of loops:",[214,215,216,224,229],"ul",{},[217,218,219,223],"li",{},[220,221,222],"code",{},"while"," loop",[217,225,226,223],{},[220,227,228],{},"repeat while",[217,230,231,223],{},[220,232,233],{},"for",[235,236,238],"h2",{"id":237},"while-loop","While Loop",[204,240,241],{},"A while loop is a control-flow construct that repeatedly executes a line of block of code as long as a specified boolean condition evaluates to true. The loop begins with an initial evaluation of the condition to determine whether execution should proceed. After each iteration, the condition is re-evaluated, and the cycle repeats accordingly.",[243,244,250],"pre",{"className":245,"code":246,"filename":247,"language":248,"meta":249,"style":249},"language-kh shiki shiki-themes material-theme-lighter one-light one-dark-pro","while(condition){\n  # code ...\n}\n","syntax","kh","",[220,251,252,271,278],{"__ignoreMap":249},[253,254,257,260,264,268],"span",{"class":255,"line":256},"line",1,[253,258,222],{"class":259},"sQsOY",[253,261,263],{"class":262},"sM89C","(",[253,265,267],{"class":266},"s8dPH","condition",[253,269,270],{"class":262},"){\n",[253,272,274],{"class":255,"line":273},2,[253,275,277],{"class":276},"seacL","  # code ...\n",[253,279,281],{"class":255,"line":280},3,[253,282,283],{"class":262},"}\n",[204,285,286],{},[287,288,289],"strong",{},"Example:",[243,291,293],{"className":245,"code":292,"language":248,"meta":249,"style":249},"while(2 \u003C 4){\n  print(\"always true\");\n}\n",[220,294,295,314,335],{"__ignoreMap":249},[253,296,297,299,301,305,309,312],{"class":255,"line":256},[253,298,222],{"class":259},[253,300,263],{"class":262},[253,302,304],{"class":303},"sriKn","2",[253,306,308],{"class":307},"sB4Xn"," \u003C",[253,310,311],{"class":303}," 4",[253,313,270],{"class":262},[253,315,316,320,322,326,330,332],{"class":255,"line":273},[253,317,319],{"class":318},"spnjr","  print",[253,321,263],{"class":262},[253,323,325],{"class":324},"sVH1b","\"",[253,327,329],{"class":328},"spZWa","always true",[253,331,325],{"class":324},[253,333,334],{"class":262},");\n",[253,336,337],{"class":255,"line":280},[253,338,283],{"class":262},[204,340,341,343,344,347],{},[220,342,329],{}," will be repeatedly printed infinite times because the condition ",[220,345,346],{},"2 \u003C 4"," is always true.",[349,350,351],"caution",{},"Never write an infinite loop that runs endlessly!",[235,353,355],{"id":354},"repeat-while-loop","Repeat While Loop",[204,357,358,359,361,362,364],{},"Unlike ",[220,360,222],{}," loop, ",[220,363,228],{}," loop executes the block of code once before evaulating the condition to determine whether the cycle should continue or terminate immediately.",[243,366,368],{"className":245,"code":367,"filename":247,"language":248,"meta":249,"style":249},"repeat {\n  #code ...\n}while(condition);\n",[220,369,370,378,383],{"__ignoreMap":249},[253,371,372,375],{"class":255,"line":256},[253,373,374],{"class":259},"repeat",[253,376,377],{"class":262}," {\n",[253,379,380],{"class":255,"line":273},[253,381,382],{"class":276},"  #code ...\n",[253,384,385,388,390,392,394],{"class":255,"line":280},[253,386,387],{"class":262},"}",[253,389,222],{"class":259},[253,391,263],{"class":262},[253,393,267],{"class":266},[253,395,334],{"class":262},[204,397,398],{},[287,399,289],{},[243,401,403],{"className":245,"code":402,"filename":220,"language":248,"meta":249,"style":249},"int i = 0;\nrepeat{\n  print(\"hello, new world\\n\");\n  i++;\n} while(i \u003C 10);\n",[220,404,405,422,429,448,459],{"__ignoreMap":249},[253,406,407,410,413,416,419],{"class":255,"line":256},[253,408,409],{"class":266},"int",[253,411,412],{"class":266}," i",[253,414,415],{"class":307}," =",[253,417,418],{"class":303}," 0",[253,420,421],{"class":262},";\n",[253,423,424,426],{"class":255,"line":273},[253,425,374],{"class":259},[253,427,428],{"class":262},"{\n",[253,430,431,433,435,437,440,444,446],{"class":255,"line":280},[253,432,319],{"class":318},[253,434,263],{"class":262},[253,436,325],{"class":324},[253,438,439],{"class":328},"hello, new world",[253,441,443],{"class":442},"scPpd","\\n",[253,445,325],{"class":324},[253,447,334],{"class":262},[253,449,451,454,457],{"class":255,"line":450},4,[253,452,453],{"class":266},"  i",[253,455,456],{"class":307},"++",[253,458,421],{"class":262},[253,460,462,465,467,469,472,474,477],{"class":255,"line":461},5,[253,463,464],{"class":262},"} ",[253,466,222],{"class":259},[253,468,263],{"class":262},[253,470,471],{"class":266},"i",[253,473,308],{"class":307},[253,475,476],{"class":303}," 10",[253,478,334],{"class":262},[480,481,482,485,486,489,490,493,494,496],"note",{},[220,483,484],{},"repeat-while"," loop is entirely the same as ",[220,487,488],{},"do-while"," loop in most other programming languages, the difference is just the keyword ",[220,491,492],{},"do"," is changed to ",[220,495,374],{},".",[235,498,500],{"id":499},"for-loop","For Loop",[204,502,503,505],{},[220,504,233],{}," loop is another control flow that repeatedly executes based on a header that consists of 3 different functional parts.",[214,507,508,514,520],{},[217,509,510,513],{},[287,511,512],{},"Initialization",": executed once before the loop begins, this part typically defines a loop control variable.",[217,515,516,519],{},[287,517,518],{},"Condition",": a boolean expression evaluated before each iteration to determine whether the iteration should continue or not.",[217,521,522,525],{},[287,523,524],{},"Updation",": executed at the end of each iteration, this part modifies the loop control variable, usually to move the loop closer to its termination state.",[243,527,529],{"className":245,"code":528,"filename":247,"language":248,"meta":249,"style":249},"for(initialization; condition; updation){ \n  # code ...\n}\n",[220,530,531,553,557],{"__ignoreMap":249},[253,532,533,535,537,540,543,545,547,550],{"class":255,"line":256},[253,534,233],{"class":259},[253,536,263],{"class":262},[253,538,539],{"class":266},"initialization",[253,541,542],{"class":262},"; ",[253,544,267],{"class":266},[253,546,542],{"class":262},[253,548,549],{"class":266},"updation",[253,551,552],{"class":262},"){ \n",[253,554,555],{"class":255,"line":273},[253,556,277],{"class":276},[253,558,559],{"class":255,"line":280},[253,560,283],{"class":262},[204,562,563],{},[287,564,289],{},[243,566,568],{"className":245,"code":567,"language":248,"meta":249,"style":249},"for(int i = 0; i \u003C 10; i++){\n  print(\"hello, world!\");\n}\n",[220,569,570,600,615],{"__ignoreMap":249},[253,571,572,574,576,578,580,582,584,586,588,590,592,594,596,598],{"class":255,"line":256},[253,573,233],{"class":259},[253,575,263],{"class":262},[253,577,409],{"class":266},[253,579,412],{"class":266},[253,581,415],{"class":307},[253,583,418],{"class":303},[253,585,542],{"class":262},[253,587,471],{"class":266},[253,589,308],{"class":307},[253,591,476],{"class":303},[253,593,542],{"class":262},[253,595,471],{"class":266},[253,597,456],{"class":307},[253,599,270],{"class":262},[253,601,602,604,606,608,611,613],{"class":255,"line":273},[253,603,319],{"class":318},[253,605,263],{"class":262},[253,607,325],{"class":324},[253,609,610],{"class":328},"hello, world!",[253,612,325],{"class":324},[253,614,334],{"class":262},[253,616,617],{"class":255,"line":280},[253,618,283],{"class":262},[204,620,621,622,624],{},"In the typical ",[220,623,222],{}," loop you normally write:",[243,626,628],{"className":245,"code":627,"language":248,"meta":249,"style":249},"int i = 0;\nwhile(i \u003C 10){\n  print(\"hello, world\\n\");\n  i++;\n}\n",[220,629,630,642,656,673,681],{"__ignoreMap":249},[253,631,632,634,636,638,640],{"class":255,"line":256},[253,633,409],{"class":266},[253,635,412],{"class":266},[253,637,415],{"class":307},[253,639,418],{"class":303},[253,641,421],{"class":262},[253,643,644,646,648,650,652,654],{"class":255,"line":273},[253,645,222],{"class":259},[253,647,263],{"class":262},[253,649,471],{"class":266},[253,651,308],{"class":307},[253,653,476],{"class":303},[253,655,270],{"class":262},[253,657,658,660,662,664,667,669,671],{"class":255,"line":280},[253,659,319],{"class":318},[253,661,263],{"class":262},[253,663,325],{"class":324},[253,665,666],{"class":328},"hello, world",[253,668,443],{"class":442},[253,670,325],{"class":324},[253,672,334],{"class":262},[253,674,675,677,679],{"class":255,"line":450},[253,676,453],{"class":266},[253,678,456],{"class":307},[253,680,421],{"class":262},[253,682,683],{"class":255,"line":461},[253,684,283],{"class":262},[204,686,687,689,690,692],{},[220,688,233],{}," loop is simply like a shortcut that you can write your ",[220,691,222],{}," loop in fewer lines of code!",[694,695,696,697,699],"warning",{},"The ",[220,698,267],{}," must be a valid boolean expression, others such as assignment is not allowed and shall result in compilation error.",[701,702,703],"style",{},"html pre.shiki code .sQsOY, html code.shiki .sQsOY{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#A626A4;--shiki-default-font-style:inherit;--shiki-dark:#C678DD;--shiki-dark-font-style:inherit}html pre.shiki code .sM89C, html code.shiki .sM89C{--shiki-light:#90A4AE;--shiki-default:#383A42;--shiki-dark:#ABB2BF}html pre.shiki code .s8dPH, html code.shiki .s8dPH{--shiki-light:#90A4AE;--shiki-default:#E45649;--shiki-dark:#E06C75}html pre.shiki code .seacL, html code.shiki .seacL{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#A0A1A7;--shiki-default-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sriKn, html code.shiki .sriKn{--shiki-light:#F76D47;--shiki-default:#986801;--shiki-dark:#D19A66}html pre.shiki code .sB4Xn, html code.shiki .sB4Xn{--shiki-light:#39ADB5;--shiki-default:#383A42;--shiki-dark:#ABB2BF}html pre.shiki code .spnjr, html code.shiki .spnjr{--shiki-light:#6182B8;--shiki-default:#4078F2;--shiki-dark:#61AFEF}html pre.shiki code .sVH1b, html code.shiki .sVH1b{--shiki-light:#39ADB5;--shiki-default:#50A14F;--shiki-dark:#98C379}html pre.shiki code .spZWa, html code.shiki .spZWa{--shiki-light:#91B859;--shiki-default:#50A14F;--shiki-dark:#98C379}html pre.shiki code .scPpd, html code.shiki .scPpd{--shiki-light:#90A4AE;--shiki-default:#0184BC;--shiki-dark:#56B6C2}",{"title":249,"searchDepth":273,"depth":273,"links":705},[706,707,708],{"id":237,"depth":273,"text":238},{"id":354,"depth":273,"text":355},{"id":499,"depth":273,"text":500},"Automation is the art of handling repetitive tasks.","md",null,{},{"icon":24},{"title":53,"description":709},"VnWHWoUxyotMaQg9e_Nq7oVSqOBEo3KvDzl2i4sa1oc",[717,719],{"title":49,"path":50,"stem":51,"description":718,"icon":24,"children":-1},"Everything you need to know about conditional statements in Cambo.",{"title":57,"path":58,"stem":59,"description":720,"icon":24,"children":-1},"Introduction to functions in Cambo.",1774971227270]