spl

systems programming language
git clone http://frotz.net/git/spl.git
Log | Files | Refs | README | LICENSE

1030-flow-control.spl (436B)


      1 fn hex(n i32) {
      2 	_hexout_(n);
      3 }
      4 
      5 fn count(n i32) {
      6 	while (n > 0) {
      7 		hex(n);
      8 		if (n == 3) {
      9 			break;
     10 		}
     11 		n = n - 1;
     12 	}
     13 }
     14 
     15 fn count_even(n i32) {
     16 	while (n > 0) {
     17 		n--;
     18 		if ((n & 1) == 1) {
     19 			continue;
     20 		}
     21 		_hexout_(n);
     22 	}
     23 }
     24 
     25 fn start() i32 {
     26 	if (true) {
     27 		hex(0x10101010);
     28 	} else {
     29 		hex(0x20202020);
     30 	}
     31 
     32 	if (false) {
     33 		hex(0x30303030);
     34 	} else {
     35 		hex(0x40404040);
     36 	}
     37 
     38 	count(2);
     39 
     40 	count(7);
     41 
     42 	count_even(7);
     43 
     44 	return 1;
     45 }