StringReduceRight

Run the provided udf over a reversed string to reduce the values to a single output

Method Signature

StringReduceRight(list=[string], callback=[function:BiFunction], initialValue=[any], delimiter=[string], includeEmptyFields=[boolean], multiCharacterDelimiter=[boolean])

Arguments

Argument
Type
Required
Description
Default

list

string

true

callback

function:BiFunction

true

The function to invoke for each item. The function will be passed 3 arguments: the value, the index, the array.

initialValue

any

false

The initial value of the reduction

delimiter

string

false

,

includeEmptyFields

boolean

false

false

multiCharacterDelimiter

boolean

false

true

Examples

Simple stringReduceRight Example

Demonstrate how the function works from right to left.

Run Example

myString = "abcd";
newString = stringReduceRight( myString, ( Any prev, Any next, Any idx, Any arr ) => {
	return prev & next & idx;
}, "" );
writedump( newString );

Result: d4c3b2a1

How Do You Do This In Boxlang?

This function will be added to Boxlang in Version 6. But if you need to reverse a string now, use the reverse() function.

Run Example

myString = "abcd";
newString = myString.reverse();
writedump( newString );

Result: dcba

Last updated

Was this helpful?