Question

I have an array in TTCN-3 that I want to use the command permutation on. That is usually done like this:

myArray := { permutation( myArray[0], myArray[1], myArray[2] ) };

The result is that when I expect the result to be myArray, the order of the elements doesn't matter.

However, this requires hard-coding of the actual values in the array, like above, where I specifically tell permutation what values of the array I want present. I am now in a situation where I have an array that I from the code don't know the size of. I can find the size of my array with

sizeof(myArray);

so if I could use that value that I get in runtime to specify how the permutation should be done, that would be great. What I want to accomplish is something like this

myArray := { permutation( myArray[0], ... , myArray[n] ) };

where n is the size of the array, which I do not know from the code.

Was it helpful?

Solution

In your special case maybe a "set of" would be the desired construct. A set of values matches a list of same values in any order.

Nevertheless there is a processed change request for the TTCN-3 language at (CR6088), extending the BNF to support also dynamic lists as parameters for superset, subset, permutation and complement.

The CR was accepted and will be published in the new TTCN-3 Edition 4.5.1 (for details please Section B.1.3.3). The 4.5.1 TTCN-3 Core Language Standard should be available at http://www.ttcn-3.org/.

Please find below the example (from the standard document) that shows the usage as defined by Edition 4.5.1:

type record of integer RoI;
template RoI t_RoI1 := {1, 2, *};
template RoI t_RoI2 := {permutation(0, all from t_RoI1), 4, 5}; 
// results in {permutation(0, 1, 2, *), 4, 5}

Best regards,
Bogdan

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top