<commit_before>// =============================================================================
// =ALEKSI - WALK
// =============================================================================
////
//// @group aleksi-lists
//// @author [<NAME>](http://yoannis.me)

@import "SassyLists";
@import "aleksi/general/throw";
@import "aleksi/maps/map-walk";
@import "aleksi/lists/set-list-separator";

// =walk( $list, $func[, $args... ])
// -----------------------------------------------------------------------------
/// Applies the given function to each value inside a list, arglist or a map.
/// **Note**: SassyLists offers the similar `sl-walk()` function. The difference
/// is that Aleksi's `walk()` function will delegate to `map-walk()` when the
/// first argument is a map.
/// **Note**: When passed a simple value (not a list, arglist or map), it will
/// apply the function to it and return the result inside a single item list.
///
/// @param {list|map} $list [default] - The values to walk over.
/// @param {string} $func - The name of the function to apply to each value.
/// @param {arglist} $args... - Additional arguments passed to '$func`.
///
/// @return {list|map} - The list, arglist or map with modified values.
/// @throw Warning when walking over a simple value.
///
/// @example scss
///   $foo: map-walk(('foo': 'bar', 'bar': 'baz'), 'to-upper-case');
///     // => ('foo': 'BAR', 'bar': 'BAZ')
///   $bar: list-walk('foo' 'bar' 'baz', 'to-upper-case');
///     // => 'FOO' 'BAR' 'BAZ'
///   $baz: list-walk('foo', 'to-upper-case');
///     // => 'FOO'
///
/// @access public
/// @since 0.1.0

@function walk( $list, $func, $args... )
{
  @if type-of($list) == 'map' {
    @return map-walk($list, $func, $args...);
  }

  @else if is-list($list) {
    @return list-walk($list, $func, $args...);
  }

  $w: throw-warning("Walking over a simple value #{inspect($list)} — resulting value will be returned inside a list.");
  @return call($func, $list, $args...);
}

// =list-walk( $list, $func[, $args... ])
// -----------------------------------------------------------------------------
/// Applies the given function to each value inside a list or arglist or a map.
/// **Note**: SassyLists offers the similar `sl-walk()` function but it throws
/// an wrong-type error in Libsass when passing a function that only accepts one
/// argument and an empty arglist as third parameter.
///
/// @param {list} $list [default] - The list of values to walk over.
/// @param {string} $func - The name of the function to apply to each value.
/// @param {arglist} $args... - Additional arguments passed to '$func`.<commit_msg>fix walk fuction to always return a list<commit_after>// =============================================================================
// =ALEKSI - WALK
// =============================================================================
////
//// @group aleksi-lists
//// @author [<NAME>](http://yoannis.me)

@import "SassyLists";
@import "SassyCast";
@import "aleksi/general/throw";
@import "aleksi/maps/map-walk";
@import "aleksi/lists/set-list-separator";

// =walk( $list, $func[, $args... ])
// -----------------------------------------------------------------------------
/// Applies the given function to each value inside a list, arglist or a map.
/// **Note**: SassyLists offers the similar `sl-walk()` function. The difference
/// is that Aleksi's `walk()` function will delegate to `map-walk()` when the
/// first argument is a map.
/// **Note**: When passed a simple value (not a list, arglist or map), it will
/// apply the function to it and return the result inside a single item list.
///
/// @param {list|map} $list [default] - The values to walk over.
/// @param {string} $func - The name of the function to apply to each value.
/// @param {arglist} $args... - Additional arguments passed to '$func`.
///
/// @return {list|map} - The list, arglist or map with modified values.
/// @throw Warning when walking over a simple value.
///
/// @example scss
///   $foo: map-walk(('foo': 'bar', 'bar': 'baz'), 'to-upper-case');
///     // => ('foo': 'BAR', 'bar': 'BAZ')
///   $bar: list-walk('foo' 'bar' 'baz', 'to-upper-case');
///     // => 'FOO' 'BAR' 'BAZ'
///   $baz: list-walk('foo', 'to-upper-case');
///     // => 'FOO'
///
/// @access public
/// @since 0.1.0

@function walk( $list, $func, $args... )
{
  @if type-of($list) == 'map' {
    @return map-walk($list, $func, $args...);
  }

  @else if is-list($list) {
    @return list-walk($list, $func, $args...);
  }

  $w: throw-warning("Walking over a simple value #{inspect($list)} — resulting value will be returned inside a list.");
  // @return call($func, $list, $args...);
  @return list-walk(to-list($list), $func, $args...);
}

// =list-walk( $list, $func[, $args... ])
// -----------------------------------------------------------------------------
/// Applies the given function to each value inside a list or arglist or a map.
/// **Note**: SassyLists offers the similar `sl-walk()` function but it throws
/// an wrong-type error in Libsass when passing a function that only accepts one
/// argument and an empty arglist as third parameter.
///
/// @param {list} $list [default] - The list of values to walk over.
/// @param {string} $func - The name of the function to apply to each value.
/// @param {arglist} $args... - Additional arguments passed to '$func`.
{'fraction_non_alphanumeric': 0.2963376092210448, 'fraction_numerical': 0.0011154489682097045, 'mean_word_length': 2.4935064935064934, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3850943', 'n_tokens_mistral': 1613, 'n_tokens_neox': 1544, 'n_words': 578}