You are currently viewing the GMLscripts.com static mirror. Forum access and script submissions are not available through this mirror.

Invert GMLscripts.com

implode_real

Returns a string of elements from a given array of real values and separated by a delimiter.

array[0] = 10;
array[1] = 21;
array[2] = 13;
array[3] = 3;
array[4] = 18;
array[5] = 15;

numbers = implode(",", array);

//  numbers == "10,21,13,3,18,15"
implode_real(del, arr)
Returns a string of elements from a given array of real values and separated by a delimiter.
COPY/// @func   implode_real(del, arr)
///
/// @desc   Returns a string of elements from a given array
///         of real values and separated by a delimiter.
///
///         eg. implode_real(":", [1, 2, 3, 4]) == "1:2:3:4"
///
/// @param  {string}    del         delimiter character(s)
/// @param  {array}     arr         array of real numbers
///
/// @return {string}    string of delimited elements
///
/// GMLscripts.com/license

function implode_real(del, arr)
{
    var len = array_length(arr);
    if (len == 0) return "";
    var out = "";
    var ind = 0;
    repeat (len-1) {
        out += string(arr[ind]) + del;
        ind++;
    }
    out += string(arr[ind]);
    return out;
}

Contributors: xot

GitHub: View · Commits · Blame · Raw