/// Replace a value in a list
///
/// @author Hugo Giraudel
/// @access public
/// @link https://goo.gl/NCFTHF
///
/// @param {list} $list - the list which contains the value you wish to replace
/// @param {*} $old-value - the value you wish to replace
/// @param {*} $new-value - what you wish to replace the old value with
/// @param {bool} $recursive [false] - used if the target list is nested
///
/// @return {list} - updated list
@function list-replace($list, $old-value, $new-value, $recursive: false) {
    $result: ();

    @for $i from 1 through length($list) {
        @if type-of(nth($list, $i)) == list and $recursive {
            $result: append($result, list-replace(nth($list, $i), $old-value, $new-value, $recursive));
        } @else {
            @if nth($list, $i) == $old-value {
                $result: append($result, $new-value);
            } @else {
                $result: append($result, nth($list, $i));
            }
        }
    }

    @return $result;
}