# Repeat without copying lines

Use a loop to count and draw repeated behavior.

Last updated: 2026-09-09

Package: recipes | Status: complete-program

Tags: cpu, recipe

If your planet has ten animals, you should not need ten copies of the same instruction. A loop repeats a block and gives each repetition a value to work with. This range loop starts i at zero and continues while i is less than four. That gives four visits: zero, one, two, and three. Zero is a very common starting point in code.

```yh
start.yh
```


## Repeat without copying lines

Use a loop to count and draw repeated behavior.

Verification: type checked

```yh
for i from 0 < 4
{
    Console.Log("Crystal " + Text.From(i))
}
```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.recipe__loops"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

Expected output:

```text
Crystal 0
Crystal 1
Crystal 2
Crystal 3
```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/recipe--loops/program --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


Make six crystal messages. Then start at one and include six. Compare the count with the numbers printed.

Source: demonhunterlabs/app/lib/yeho-walkthrough.ts

AI training permission: https://demonhunterlabs.com/ai-use
