JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

Profile: desktop, common

Overview

Library of static Sequence Utilities that can be used to perform common operations, such as adding or concatenating. Also provides a generic fold operation (ala. Haskell or ML) that can be used to reduce a generic list of Objects. Currently there is only type support for Numbers, Integers, and Objects.

Profile: common

Inherited Variables

Script Function Summary

public avg(seq: Number[]) : Number

Calculates the mathematical average of a sequence of numbers.

Calculates the mathematical average of a sequence of numbers. This function is typed for Number sequences.

Parameters
seq
A sequence of Numbers
Returns
Number
The sum of the sequence
 
public avg(seq: Integer[]) : Integer

Calculates the mathematical average of a sequence of numbers.

Calculates the mathematical average of a sequence of numbers. This function is typed for Integer sequences.

Parameters
seq
A sequence of Integers
Returns
Integer
The sum of the sequence
 
public characterSequence(start: java.lang.String, end: java.lang.String) : java.lang.Object[]

A character sequence generator.

A character sequence generator. This function generates a sequence of one-character strings starting from the first character of the start string and ending with the first character of the end string.

Parameters
start
The character that starts the sequence.
end
The character that ends the sequence.
Returns
Object[]
A sequence of one-character strings.
 
public concat(seq: java.lang.String[]) : java.lang.String

Concatenates all the elements of a String sequence, returning a single merged String.

Concatenates all the elements of a String sequence, returning a single merged String.

Parameters
seq
A sequence of Strings
Returns
String
A single concatenated value
 
public fold(ident: Number, seq: Number[], func: com.sun.javafx.functions.Function2) : Number

Generic fold function typed for Number sequences.

Generic fold function typed for Number sequences. This function takes an identity Number, a sequence of Numbers, and a reduce function, and returns a single value.

This function performs what is known as a left fold in functional languages. The basic algorithm is that the ident value and first element of the list are passed in to the given reduce function, resulting in a single value. That value is then passed together with the second element of the list back into the reduce function resulting in a single value again. This process repeats until there are no elements left in the list and a single return value results.

For a more thorough explanation of how the fold operator works, please refer to the following article: http://en.wikipedia.org/wiki/Fold_(higher-order_function)

Parameters
ident
The identity value
seq
A sequence of Numbers
func
A reduce function
Returns
Number
A single value that is the result of applying the reduce function to all the elements in the sequence.
 
public fold(ident: Integer, seq: Integer[], func: com.sun.javafx.functions.Function2) : Integer

Generic fold function typed for Integer sequences.

Generic fold function typed for Integer sequences. This function takes an identity Integer, a sequence of Integers, and a reduce function, and returns a single value.

This function performs what is known as a left fold in functional languages. The basic algorithm is that the ident value and first element of the list are passed in to the given reduce function, resulting in a single value. That value is then passed together with the second element of the list back into the reduce function resulting in a single value again. This process repeats until there are no elements left in the list and a single return value results.

For a more thorough explanation of how the fold operator works, please refer to the following article: http://en.wikipedia.org/wiki/Fold_(higher-order_function)

Parameters
ident
The identity value
seq
A sequence of Integers
func
A reduce function
Returns
Integer
A single value that is the result of applying the reduce function to all the elements in the sequence.
 
public fold(ident: java.lang.Object, seq: java.lang.Object[], func: com.sun.javafx.functions.Function2) : java.lang.Object

Generic fold function typed for Object sequences.

Generic fold function typed for Object sequences. This function takes an identity Object, a sequence of Objects, and a reduce function, and returns a single value.

This function performs what is known as a left fold in functional languages. The basic algorithm is that the ident value and first element of the list are passed in to the given reduce function, resulting in a single value. That value is then passed together with the second element of the list back into the reduce function resulting in a single value again. This process repeats until there are no elements left in the list and a single return value results.

For a more thorough explanation of how the fold operator works, please refer to the following article: http://en.wikipedia.org/wiki/Fold_(higher-order_function)

Parameters
ident
The identity value
seq
A sequence of Objects
func
A reduce function
Returns
Object
A single value that is the result of applying the reduce function to all the elements in the sequence.
 
public join(seq: java.lang.String[], delimiter: java.lang.String) : java.lang.String

Joins all the elements of a String sequence using the specified delimiter String between elements.

Joins all the elements of a String sequence using the specified delimiter String between elements. Thre result is a single merged String with one less delimiter than the size of the input sequence.

Parameters
seq
A sequence of Strings
delimiter
Returns
String
A single value joined by the delimiter
 
public stableUpdate(original: java.lang.Object[], updated: java.lang.Object[]) : java.lang.Object[]

Reorders the updated sequence to match the order of the original sequence.

Reorders the updated sequence to match the order of the original sequence. Specifically, the following constraints are obeyed:

  • The order of nodes that exist in both sequences are guaranteed to be the same
  • Elements that exist in the source, but not the destination will get added to the end
  • Elements that exist in the destination but not the source will get deleted

The resulting sequence will be returned from this function (updates are not made in place).

If the same element is in either sequence twice, the duplicates will be preserved as long as there is at least one instance of the element in both the original and updates sequences.

Parameters
original
The sequence that the destination will be updated from
updated
The sequence to update in place wrapped with a SequenceHolder
Returns
Object[]
 
public sum(seq: Number[]) : Number

Adds up all the elements of a sequence returning the total.

Adds up all the elements of a sequence returning the total. This function is typed for Number sequences.

Parameters
seq
A sequence of Numbers
Returns
Number
The sum of the sequence
 
public sum(seq: Integer[]) : Integer

Adds up all the elements of a sequence returning the total.

Adds up all the elements of a sequence returning the total. This function is typed for Integer sequences.

Parameters
seq
A sequence of Integers
Returns
Integer
The sum of the sequence
 

Inherited Functions