fold

fun fold(operator: String, terms: List<Term>): Struct

Folds the Terms in terms from left to right, creating binary structures having operator as functor. Let f be the value of operator, and let t_i be the i-th term in terms. Then, this method constructs the Structure

f(t_1, f(t_2, ... f(t_n-1, t_n) ...))

Of course, this method will return an instance of either Tuple in case the argument operator is adequate.

Return

a new Struct (or of some particular sub-type of Struct)

Parameters

operator

the functor of the Structures used to fold the terms

terms

the KtList of Terms to be folded

Throws

if terms has less than 2 items


fun fold(operator: String, terms: List<Term>, terminal: Term?): Struct

Folds the Terms in terms from left to right, creating binary structures having operator as functor. Let f be the value of operator, and let t_i be the i-th term in terms. Then, if terminal is non-null, this method constructs the Structure

f(t_1, f(t_2, ... f(t_n, T) ...))

where T is the value of terminal, and t_n is the last item in terms. Conversely, if terminal is null, this method constructs the Structure

f(t_1, f(t_2, ... f(t_n-1, t_n) ...))

Of course, this method will return an instance of either List, or Tuple in case the arguments operator and terminal are adequate.

Return

a new Struct (or of some particular sub-type of Struct)

Parameters

operator

the functor of the Structures used to fold the terms

terms

the KtList of Terms to be folded

terminal

the termination Term used as the deepest one in the returned Struct, or null if t_n should be used instead

Throws

if terms has less than 2 items


fun fold(operator: String, terms: Sequence<Term>, terminal: Term?): Struct

Folds the Terms in terms from left to right, creating binary structures having operator as functor. Let f be the value of operator, and let t_i be the i-th term in terms. Then, if terminal is non-null, this method constructs the Structure

f(t_1, f(t_2, ... f(t_n, T) ...))

where T is the value of terminal, and t_n is the last item in terms. Conversely, if terminal is null, this method constructs the Structure

f(t_1, f(t_2, ... f(t_n-1, t_n) ...))

Of course, this method will return an instance of either List, or Tuple in case the arguments operator and terminal are adequate.

Return

a new Struct (or of some particular sub-type of Struct)

Parameters

operator

the functor of the Structures used to fold the terms

terms

the Sequence of Terms to be folded

terminal

the termination Term used as the deepest one in the returned Struct, or null if t_n should be used instead

Throws

if terms has less than 2 items


fun fold(operator: String, terms: Sequence<Term>): Struct

Folds the Terms in terms from left to right, creating binary structures having operator as functor. Let f be the value of operator, and let t_i be the i-th term in terms. Then, this method constructs the Structure

f(t_1, f(t_2, ... f(t_n-1, t_n) ...))

Of course, this method will return an instance of either Tuple in case the argument operator is adequate.

Return

a new Struct (or of some particular sub-type of Struct)

Parameters

operator

the functor of the Structures used to fold the terms

terms

the Sequence of Terms to be folded

Throws

if terms has less than 2 items


fun fold(operator: String, terms: Iterable<Term>, terminal: Term?): Struct

Folds the Terms in terms from left to right, creating binary structures having operator as functor. Let f be the value of operator, and let t_i be the i-th term in terms. Then, if terminal is non-null, this method constructs the Structure

f(t_1, f(t_2, ... f(t_n, T) ...))

where T is the value of terminal, and t_n is the last item in terms. Conversely, if terminal is null, this method constructs the Structure

f(t_1, f(t_2, ... f(t_n-1, t_n) ...))

Of course, this method will return an instance of either List, or Tuple in case the arguments operator and terminal are adequate.

Return

a new Struct (or of some particular sub-type of Struct)

Parameters

operator

the functor of the Structures used to fold the terms

terms

the Iterable of Terms to be folded

terminal

the termination Term used as the deepest one in the returned Struct, or null if t_n should be used instead

Throws

if terms has less than 2 items


fun fold(operator: String, terms: Iterable<Term>): Struct

Folds the Terms in terms from left to right, creating binary structures having operator as functor. Let f be the value of operator, and let t_i be the i-th term in terms. Then, this method constructs the Structure

f(t_1, f(t_2, ... f(t_n-1, t_n) ...))

Of course, this method will return an instance of either Tuple in case the argument operator is adequate.

Return

a new Struct (or of some particular sub-type of Struct)

Parameters

operator

the functor of the Structures used to fold the terms

terms

the Iterable of Terms to be folded

Throws

if terms has less than 2 items


fun fold(operator: String, vararg terms: Term, terminal: Term?): Struct

Folds the Terms in terms from left to right, creating binary structures having operator as functor. Let f be the value of operator, and let t_i be the i-th term in terms. Then, if terminal is non-null, this method constructs the Structure

f(t_1, f(t_2, ... f(t_n, T) ...))

where T is the value of terminal, and t_n is the last item in terms. Conversely, if terminal is null, this method constructs the Structure

f(t_1, f(t_2, ... f(t_n-1, t_n) ...))

Of course, this method will return an instance of either List, or Tuple in case the arguments operator and terminal are adequate.

Return

a new Struct (or of some particular sub-type of Struct)

Parameters

operator

the functor of the Structures used to fold the terms

terms

the vararg array of Terms to be folded

terminal

the termination Term used as the deepest one in the returned Struct, or null if t_n should be used instead

Throws

if terms has less than 2 items


fun fold(operator: String, vararg terms: Term): Struct

Folds the Terms in terms from left to right, creating binary structures having operator as functor. Let f be the value of operator, and let t_i be the i-th term in terms. Then, this method constructs the Structure

f(t_1, f(t_2, ... f(t_n-1, t_n) ...))

Of course, this method will return an instance of either Tuple in case the argument operator is adequate.

Return

a new Struct (or of some particular sub-type of Struct)

Parameters

operator

the functor of the Structures used to fold the terms

terms

the vararg array of Terms to be folded

Throws

if terms has less than 2 items