Created
January 24, 2014 13:28
-
-
Save dmitry-ilyashevich/8597235 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.3.0.rc.2) | |
// Compass (v1.0.0.alpha.17) | |
// ---- | |
// Counts the number of occurrences of each value of $list | |
// ------------------------------------------------------------------------------- | |
// @param $list [List] : list | |
// ------------------------------------------------------------------------------- | |
// @return [Map] | |
@function count-values($list) { | |
$map: (); | |
@each $item in $list { | |
$index: map-get($map, $item); | |
$value: if($index, $index + 1, 1); | |
$map: map-merge($map, ($item: $value)); | |
} | |
@return $map; | |
} | |
$list: test string banana abc string a banana test; | |
$count: count-values($list); | |
sass { | |
count-values: inspect($count); | |
} |
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 { | |
count-values: (test: 2, string: 2, banana: 2, abc: 1, a: 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment