3.5.2.2.3 Pattern


The pattern( ) function can be used to generate patterned numeric or text data.

  • To generate patterned numeric data, the syntax is pattern(from, to, inc, value repeat count, sequence repeat count)
    In which,
    from specifies the starting value of the generated data sequence
    to specifies the ending value of the generated data sequence
    inc specifies the increment within the generated data sequence
    value repeat count specifies how many times each value repeats itself in the generated data sequence
    sequence repeat count specifies how many times each whole data sequence repeats itself in the generated dataset
  • To generate patterned text data, the syntax is pattern(string source, value repeat count, sequence repeat count)
    In which,
    string source specifies the string series you would like to use to generate. It can be a string array, or quoted string separated by pipe(|), comma(,) or space, or a range variable.
    value repeat count specifies how many times each value repeats itself in the generated data sequence
    sequence repeat count specifies how many times each whole data sequence repeats itself in the generated dataset

Note: In order to reorder the patterned data randomly, you can use the Uniform( ) function, to specify the seed as a data range.

Examples:

//Fill in column A with numeric data with the data sequence 0 0 0.5 0.5 1 1 repeated by three times.
col(A)=pattern(0,1,0.5,2,3);

//Fill in column B with a defined string array
stringarray sa;
sa.Add("Origin");
sa.Add("Lab");
col(B)=pattern(sa, 2, 3);

//Fill in column C,D and E with quoted strings
col(C)=pattern("Origin|Lab", 2, 3);
col(D)=pattern("Origin,Lab", 2, 3);
col(E)=pattern("Origin Lab", 2, 3);

//Fill in column F with the data series in column B
col(F)=pattern(col(B), 2, 3);