I\'m trying to create a function which will output a list of numbers based on an expression given to it.
Does anyone know how I can pass an expression through a func
No. Sass does not have an eval function. The closest you can get is by using the call
function.
@function my-expression($x, $y) {
@return $x * $y + 2;
}
@function patt($expression, $b: 10) {
$result: ();
@for $i from 1 through 10 {
$result: append($result, call($expression, $i, $b));
}
@return $result;
}
$list: patt('my-expression'); // 12 22 32 42 52 62 72 82 92 102