Spaces:
Sleeping
Sleeping
Download samples/for_loop.cl from Kacemath/cl-compiler: direct link, hf CLI and curl.
- Browser
- Download file 413 Bytes
-
https://huggingface.co/spaces/Kacemath/cl-compiler/resolve/main/samples/for_loop.cl
- Command line
-
hf download hf://spaces/Kacemath/cl-compiler/samples/for_loop.cl
-
curl -L -o for_loop.cl https://huggingface.co/spaces/Kacemath/cl-compiler/resolve/main/samples/for_loop.cl
413 Bytes
| // for_loop.cl — Demonstrates the for-loop | |
| // | |
| // Syntax: for IDENT = init to limit { body } | |
| // The loop variable must be declared as 'int' before the loop. | |
| int i; | |
| int total; | |
| total = 0; | |
| // Sum 1 + 2 + 3 + 4 + 5 into 'total' | |
| for i = 1 to 5 { | |
| total = total + i; | |
| } | |
| // Nested for-loops also work | |
| int j; | |
| int product; | |
| product = 1; | |
| for i = 1 to 3 { | |
| for j = 1 to 3 { | |
| product = product * i; | |
| } | |
| } | |