Last active
August 29, 2015 14:08
-
-
Save KittyGiraudel/c36be3440dc2b5ae9ba2 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.4.6) | |
// Compass (v1.0.1) | |
// ---- | |
/// Apply `$function` with `$args` to each item from `$list`. | |
/// @param {List} $list | |
/// @param {String} $function | |
/// @param {Arglist} $args | |
/// @return {List} | |
/// @throw There is no `#{$function}` function. | |
@function walk($list, $function, $args...) { | |
@if not function-exists($function) { | |
@error "There is no `#{$function}` function."; | |
} | |
@for $i from 1 through length($list) { | |
$list: set-nth($list, $i, call($function, nth($list, $i), $args...)); | |
} | |
@return $list; | |
} | |
/// Return whether some items from `$list` passed `$function` test. | |
/// @param {List} $list | |
/// @param {String} $function | |
/// @param {Arglist} $args | |
/// @return {Boolean} | |
/// @throw There is no `#{$function}` function. | |
@function some($list, $function, $args...) { | |
@if not function-exists($function) { | |
@error "There is no `#{$function}` function."; | |
} | |
@each $item in $list { | |
@if call($function, $item, $args...) { | |
@return true; | |
} | |
} | |
@return false; | |
} | |
/// Return whether all items from `$list` passed `$function` test. | |
/// @param {List} $list | |
/// @param {String} $function | |
/// @param {Arglist} $args | |
/// @return {Boolean} | |
/// @throw There is no `#{$function}` function. | |
@function every($list, $function, $args...) { | |
@if not function-exists($function) { | |
@error "There is no `#{$function}` function."; | |
} | |
@each $item in $list { | |
@if not call($function, $item, $args...) { | |
@return false; | |
} | |
} | |
@return true; | |
} | |
/// Return a list made of the result of each function call from `$functions` with `$args`. | |
/// @param {List} $functions | |
/// @param {Arglist} $args | |
/// @return {List} | |
/// @throw There is no `#{$function}` function. | |
@function functions-walk($functions, $args...) { | |
$list: (); | |
@each $function in $functions { | |
@if not function-exists($function) { | |
@error "There is no `#{$function}` function."; | |
} | |
$list: append($list, call($function, $args...)); | |
} | |
@return $list; | |
} | |
walk { | |
walk: walk(red green blue, invert); | |
walk: walk(red green blue, lighten, 20%); | |
walk: walk(2 4 6 8 10, sqrt); | |
} | |
some { | |
some: some(round ceil floor, function-exists); | |
some: some(round ceil unknown, function-exists); | |
some: some(completely unknown function, function-exists); | |
some: some(4px 10px 20px, comparable, 42px); | |
some: some(4px 10% 20px, comparable, 42%); | |
some: some(4px 10px 20px, comparable, 42%); | |
} | |
every { | |
every: every(round ceil floor, function-exists); | |
every: every(round ceil unknown, function-exists); | |
every: every(completely unknown function, function-exists); | |
every: every(4px 10px 20px, comparable, 42px); | |
every: every(4px 10% 20px, comparable, 42%); | |
every: every(4px 10px 20px, comparable, 42%); | |
} | |
functions-walk { | |
functions-walk: functions-walk('red' 'blue' 'green', #BADA55); | |
functions-walk: functions-walk('round' 'ceil' 'floor', 3.1415279); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
walk { | |
walk: cyan #ff7fff yellow; | |
walk: #ff6666 #00e600 #6666ff; | |
walk: 1.41421 2 2.44949 2.82843 3.16228; | |
} | |
some { | |
some: true; | |
some: true; | |
some: false; | |
some: true; | |
some: true; | |
some: false; | |
} | |
every { | |
every: true; | |
every: false; | |
every: false; | |
every: true; | |
every: false; | |
every: false; | |
} | |
functions-walk { | |
functions-walk: 186 85 218; | |
functions-walk: 3 4 3; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment