@function __list-join($list, $separator: '') {
    $length: length($list);

    @if ($length == 0) {
        @return '';
    }

    $result: nth($list, 1);

    @if $length > 1 {
        @for $index from 2 through $length {
            $result: $result + $separator + nth($list, $index);
        }
    }

    @return $result;
}


@function __join($list, $separator: '', $guard: null) {
    @if $guard and __is-iteratee-call($list, $separator, $guard) {
        $separator: '';
    }

    @if __is-list-like($separator) {
        @return join($list, $separator);
    }

    @return __list-join($list, $separator);
}

/// Joins a single list into a string, 
/// similar to the native JavaScript `Array.prototype.join()`.
/// 
/// **NOTE:** This is not the same as the native Sass `join()` function.
/// 
/// @access public
/// @group List
/// @param {List} $list The list containing elements to join.
/// @param {String} $separator [''] The string separator.
/// @returns {String} Returns the joined list as a string.
/// @example scss
/// $foo: _join('a' 'b' 'c', '--');
/// // => 'a--b--c'
@function _join($args...) {
    @return call(get-function('__join'), $args...);
}
