Skip to content

Instantly share code, notes, and snippets.

@KittyGiraudel
Created November 16, 2015 14:58
Show Gist options
  • Save KittyGiraudel/cc3fe6e7450133a86bd8 to your computer and use it in GitHub Desktop.
Save KittyGiraudel/cc3fe6e7450133a86bd8 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
/// Performs right-to-left function composition.
/// The rightmost function may have any arity;
/// the remaining functions must be unary.
///
/// @see http://ramdajs.com/docs/#compose Ramda Compose
///
/// @param {List} $functions - List of functions to run
/// @param {Arglist} $args - List of args to give to last function in $functions
///
@function compose($functions, $args...) {
$result: call(nth($functions, -1), $args...);
@for $i from length($functions) - 1 through 1 {
$result: call(nth($functions, $i), $result);
}
@return $result;
}
@function pow($number, $exp) {
$value: 1;
@if $exp > 0 {
@for $i from 1 through $exp {
$value: $value * $number;
}
} @else if $exp < 0 {
@for $i from 1 through -$exp {
$value: $value / $number;
}
}
@return $value;
}
@function negate($value) {
@return $value * -1;
}
@function inc($value) {
@return $value + 1;
}
.foo {
test: compose(inc negate pow, 3, 4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment