org.omegahat.Environment.lib.Language
Class SequenceFunctions

java.lang.Object
  |
  +--org.omegahat.Environment.lib.Language.SequenceFunctions

public class SequenceFunctions
extends java.lang.Object

Class used with the addFunctionTable() method to provide "functions" for performing basic sequence operations.


Constructor Summary
SequenceFunctions()
           
 
Method Summary
static java.lang.Object[] c(java.lang.Object[] a, java.lang.Object[] b)
          Specialized version of the more general method in VarSequenceFunctions, concatenates two arrays into a single array containing the elements of both in the order they are specified.
static java.lang.Object cycle(java.lang.Object[] vals, int times)
          Replicates the specified array, repeating the sequence of elements times times, resulting in an array of length vals.length * times
static java.lang.Object cycle(java.util.Vector vals, int times)
          Take the contents of a vector and repeat them in order for a total length of vals.size() * times
static java.lang.Object[] rep(java.lang.Object obj, int length)
          repeat the specified object length times and return an array.
static java.lang.Object[] rep(java.lang.Object obj, int length, boolean copy)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SequenceFunctions

public SequenceFunctions()
Method Detail

rep

public static java.lang.Object[] rep(java.lang.Object obj,
                                     int length)
repeat the specified object length times and return an array.

rep

public static java.lang.Object[] rep(java.lang.Object obj,
                                     int length,
                                     boolean copy)

cycle

public static java.lang.Object cycle(java.lang.Object[] vals,
                                     int times)
Replicates the specified array, repeating the sequence of elements times times, resulting in an array of length vals.length * times

Omegahat Example:

[]  o = new Object[]{1,"x"}
[]  cycle(o, 3)

1 
"x"
1
"x"
1
"x"


cycle

public static java.lang.Object cycle(java.util.Vector vals,
                                     int times)
Take the contents of a vector and repeat them in order for a total length of vals.size() * times

Omegahat Example:

v = util.Vector()
v[[0]] = 1
v[[1]] = "x"
cycle(v, 3)

[1, "x", 1, "x", 1, "x"]  // vector of length 6


c

public static java.lang.Object[] c(java.lang.Object[] a,
                                   java.lang.Object[] b)
Specialized version of the more general method in VarSequenceFunctions, concatenates two arrays into a single array containing the elements of both in the order they are specified.

a = new Object[]
Returns:
array containing the elements from the first argument followed by the elements from the second argument.