Created
March 23, 2014 21:22
-
-
Save KittyGiraudel/9730068 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or 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.3.4) | |
// Compass (v1.0.0.alpha.18) | |
// ---- | |
// A Sass walk function, | |
// Calling a given function to each member of a list | |
// --- | |
// @param [list] $list: list to walk through | |
// @param [string] $function: function to apply to all members | |
// @param [argList] $args: extra arguments to pass to the function | |
// --- | |
// @return [list] $list: updated list | |
@function walk($list, $function, $args...) { | |
@if not function-exists($function) { | |
@warn "There is no `#{$function}` function."; | |
@return false; | |
} | |
@for $i from 1 through length($list) { | |
$list: set-nth($list, $i, call($function, nth($list, $i), $args...)); | |
} | |
@return $list; | |
} | |
@function add($a, $b) { | |
@return $a + $b; | |
} | |
sass { | |
// Applying color functions to a list of colors | |
test: walk(red green blue, complement); | |
test: walk(red green blue, darken, 20%); | |
// Applying string functions to a list of strings | |
test: walk(one two three, to-upper-case); | |
// Chaining two walk functions | |
test: walk(walk(3 6 9, add, 10), sqrt); | |
// Unknown function | |
test: walk(test, 'gloubiboulga'); | |
} |
This file contains hidden or 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 { | |
test: cyan purple yellow; | |
test: #990000 #001a00 #000099; | |
test: ONE TWO THREE; | |
test: 3.60555 4 4.3589; | |
test: false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment