You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

First, we need to define the CnC graph:

FindPrimes.cnc
// Declarations
// The tag values are the odd numbers in the range [3..n]
<string oddNums>;

// The prime numbers as identified by the compute step
[string->int primes];

// Step execution
// The compute step may produce a prime number (in the form of a tag instance)
(compute) -> [primes];

// Step prescription
// For each oddNums instance, there is 
<oddNums> ::  (python compute);


// Input from the environment: initialize all tags
env -> <oddNums>; 

// Output to the environment is the collection of the prime numbers
[primes] -> env;

The CnC graph states that oddNums is a Tag Collection with strings as the tags.
Currently, strings are the only supported tag types in CnC-Python.

Next, we define the Item Collection primes which has strings as tags and integer as its values. These types are defined in the format tagType->itemType before the name of the Item Collection.

We define the implementation language of the Step in the Step prescription as in (python compute). In CnC-Python, python is the only allowable value. In future releases we plan to expan this value to include other languages such as C, C++, Fortran, Matlab, etc.

env is a special keyword representing the environment and in this example we define the environment will put string tags into the oddNums Tag Collection and read the results from the primes Item Collection.

  • No labels