Spaces:
Sleeping
Sleeping
Download samples/while_loop.cl from Kacemath/cl-compiler: direct link, hf CLI and curl.
- Browser
- Download file 379 Bytes
-
https://huggingface.co/spaces/Kacemath/cl-compiler/resolve/main/samples/while_loop.cl
- Command line
-
hf download hf://spaces/Kacemath/cl-compiler/samples/while_loop.cl
-
curl -L -o while_loop.cl https://huggingface.co/spaces/Kacemath/cl-compiler/resolve/main/samples/while_loop.cl
379 Bytes
| // while_loop.cl — Demonstrates the while-loop | |
| // | |
| // Syntax: while CONDITION { body } | |
| // The condition must be a comparison ('>', '<', or '=='). | |
| int x; | |
| x = 10; | |
| // Countdown from 10 to 0 | |
| while x > 0 { | |
| x = x - 1; | |
| } | |
| // While with a nested if/else inside the body | |
| int n; | |
| n = 16; | |
| while n > 1 { | |
| if n > 8 then { | |
| n = n - 4; | |
| } else { | |
| n = n - 1; | |
| } | |
| } | |