Go to the previous, next section.

## Examples

### Creating and Initializing an Array

The code produced by this example will create a two dimensional array of 100x100 and initialize all the elements to zero.
type_node * tn = block::parse_type("double [100][100]");
block A(block::new_sym(tn, "A"));
block i(block::new_sym(cst_int, "i"));
block j(block::new_sym(cst_int, "j"));
block code(block::FOR(i, block(0), block(99),
block::FOR(j, block(0), block(99),
block(A[i][j] = block(0)))));

### A Simple Sort

The code produced by this example will sort a one-dimensional array of N doubles. Both the array and the constant variable N are provided.
var_sym * symA = (a one-dimensional array of N doubles)
var_sym * symN = (the integer value N)
block A(symA);
block N(symN);
block i(block::new_sym(cst_int, "i"));
block j(block::new_sym(cst_int, "j"));
block tmp(block::new_sym(cst_double, "tmp"));
block code(block::FOR(i, block(0), block(N - block(2)),
block::FOR(j, block(i + block(1)), block(N - block(1)),
block::IF(block(A[i] > A[j]),
block(block(tmp = A[i]),
block(A[i] = A[j]),
block(A[j] = tmp))))));

A pointer to a head of a singly linked list and the value of the value field that needs to be matched are given as input. The generated code will search through the linked list until it finds an element with the value filed matching the value and a pointer to that element is returned. If no such element is found or if the list is empty, a NULL pointer is returned.
type_node * ptr_type = (pointer to element type where
"next" is the pointer to next field
"value" is the value to be checked)
var_sym * symVal = (value to be found)