Functions
Below is a list of functions that OakGP provides. You can define your own functions by implementing org.oakgp.function.Function
.
org.oakgp.function.choice.If - A selection operator that uses a boolean expression to determine which code to evaluate.
org.oakgp.function.choice.OrElse - Returns the first argument if not
null
, else returns the second argument.org.oakgp.function.choice.SwitchEnum - A selection operator that uses the value of an enum to determine which code to evaluate.
org.oakgp.function.classify - Provides functions for classifying
Node
instances.org.oakgp.function.classify.IsNegative - Determines if a number is negative.
org.oakgp.function.classify.IsPositive - Determines if a number is positive.
org.oakgp.function.classify.IsZero - Determines if a number is zero.
org.oakgp.function.coll - Provides functions for working with collections.
org.oakgp.function.coll.Count - Determines the number of elements contained in a collection.
org.oakgp.function.compare - Provides functions for comparing the results of evaluating
Node
instances.org.oakgp.function.compare.NotEqual - Determines if two objects are not equal.
org.oakgp.function.compare.LessThan - Determines if the object represented by the first argument is less than the object represented by the second.
org.oakgp.function.compare.LessThanOrEqual - Determines if the object represented by the first argument is less than or equal to the object represented by the second.
org.oakgp.function.compare.Equal - Determines if two objects are equal.
org.oakgp.function.compare.GreaterThan - Determines if the object represented by the first argument is greater than the object represented by the second.
org.oakgp.function.compare.GreaterThanOrEqual - Determines if the object represented by the first argument is greater than or equal to the object represented by the second.
org.oakgp.function.hof - Provides higher-order functions.
org.oakgp.function.hof.Filter - Uses a function to filter the elements of a collection.
org.oakgp.function.hof.Map - Returns the result of applying a function to each element of a collection.
org.oakgp.function.hof.Reduce - Combines the elements of a collection by recursively applying a function.
org.oakgp.function.math - Provides operations for performing arithmetic.
org.oakgp.function.math.Multiply - Performs multiplication.
org.oakgp.function.math.Add - Performs addition.
org.oakgp.function.math.Subtract - Performs subtraction.
org.oakgp.function.math.Divide - Performs division.
Package: | org.oakgp.function.choice |
Description: | Provides functions for selection. |
Function: | if |
Class: | org.oakgp.function.choice.If |
Description: | A selection operator that uses a boolean expression to determine which code to evaluate. Expects three arguments:
|
Function: | orelse |
Class: | org.oakgp.function.choice.OrElse |
Description: | Returns the first argument if not null , else returns the second argument. |
Function: | switch |
Class: | org.oakgp.function.choice.SwitchEnum |
Description: | A selection operator that uses the value of an enum to determine which code to evaluate. This behaviour is similar to a Java |
Package: | org.oakgp.function.classify |
Description: | Provides functions for classifying Node instances. |
Function: | neg? |
Class: | org.oakgp.function.classify.IsNegative |
Description: | Determines if a number is negative. |
Function: | pos? |
Class: | org.oakgp.function.classify.IsPositive |
Description: | Determines if a number is positive. |
Function: | zero? |
Class: | org.oakgp.function.classify.IsZero |
Description: | Determines if a number is zero. |
Package: | org.oakgp.function.coll |
Description: | Provides functions for working with collections. |
Function: | count |
Class: | org.oakgp.function.coll.Count |
Description: | Determines the number of elements contained in a collection. |
Package: | org.oakgp.function.compare |
Description: | Provides functions for comparing the results of evaluating Node instances. |
Function: | != |
Class: | org.oakgp.function.compare.NotEqual |
Description: | Determines if two objects are not equal. Note: Equality is checked using |
Function: | < |
Class: | org.oakgp.function.compare.LessThan |
Description: | Determines if the object represented by the first argument is less than the object represented by the second. |
Function: | <= |
Class: | org.oakgp.function.compare.LessThanOrEqual |
Description: | Determines if the object represented by the first argument is less than or equal to the object represented by the second. |
Function: | = |
Class: | org.oakgp.function.compare.Equal |
Description: | Determines if two objects are equal. Note: Equality is checked using |
Function: | > |
Class: | org.oakgp.function.compare.GreaterThan |
Description: | Determines if the object represented by the first argument is greater than the object represented by the second. |
Function: | >= |
Class: | org.oakgp.function.compare.GreaterThanOrEqual |
Description: | Determines if the object represented by the first argument is greater than or equal to the object represented by the second. |
Package: | org.oakgp.function.hof |
Description: | Provides higher-order functions. A higher-order function is a function that does at least one of the following:
|
Function: | filter |
Class: | org.oakgp.function.hof.Filter |
Description: | Uses a function to filter the elements of a collection. Returns a new collection that exists of all the elements in the collection (specified by the second argument) for which the function (specified by the first argument) returns |
Function: | map |
Class: | org.oakgp.function.hof.Map |
Description: | Returns the result of applying a function to each element of a collection. Returns a new collection that exists of the result of applying the function (specified by the first argument) to each element of the collection (specified by the second argument). See: Wikipedia |
Function: | reduce |
Class: | org.oakgp.function.hof.Reduce |
Description: | Combines the elements of a collection by recursively applying a function. Expects three arguments:
|
Package: | org.oakgp.function.math |
Description: | Provides operations for performing arithmetic. |
Function: | * |
Class: | org.oakgp.function.math.Multiply |
Description: | Performs multiplication. |
Function: | + |
Class: | org.oakgp.function.math.Add |
Description: | Performs addition. |
Function: | - |
Class: | org.oakgp.function.math.Subtract |
Description: | Performs subtraction. |
Function: | / |
Class: | org.oakgp.function.math.Divide |
Description: | Performs division. |