Skip to content

Instantly share code, notes, and snippets.

@pdaoust
Created December 5, 2013 23:03
Show Gist options
  • Save pdaoust/7815628 to your computer and use it in GitHub Desktop.
Save pdaoust/7815628 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
// Filter items from a list. Each function takes an item (and additional
// arguments) and returns a boolean value indicating whether the item passed the
// filter.
@function f-filter($func, $list, $args...) {
$new-list: ();
@each $item in $list {
@if call($func, $item, $args...) {
$new-list: append($new-list, $item);
}
}
@return $new-list;
}
@function is-angular-unit($x) {
@return not not index(deg rad grad turn, unit($x));
}
p {
is-degrees-angular: is-angular-unit(3deg);
is-ems-angular: is-angular-unit(24em);
// And a functional filter.
angular-values: f-filter(is-angular-unit, (1px 24em 3deg 64grad 7 2.5turn));
}
p {
is-degrees-angular: true;
is-ems-angular: false;
angular-values: 3deg 64grad 2.5turn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment