Showing the changes to examples/ctrl/ctrl_for_loop.ck (1 of 486 files). Show all
Unified · Split
| @@ -0,0 +1,20 @@ | ||
| 1 | +// for loop ( factorial ) , -=>, *=> | |
| 2 | + | |
| 3 | +// function | |
| 4 | +fun int factorial ( int arg ) | |
| 5 | +{ | |
| 6 | + 1 => int r; | |
| 7 | + arg => int b; | |
| 8 | + for ( b ; b > 1 ; 1 -=> b ) | |
| 9 | + { | |
| 10 | + b *=> r; | |
| 11 | + } | |
| 12 | + | |
| 13 | + return r; | |
| 14 | +} | |
| 15 | + | |
| 16 | +// call the function | |
| 17 | +factorial ( 4 ) => int x; | |
| 18 | + | |
| 19 | +// test | |
| 20 | +if ( x == 24 ) <<<"success">>>; | |