Implementing calc function using vendor prefixes in LESS

Let's make a function that implements the cross-browser CSS function calc:

styles.less.calc(@name, @calc) {
  @{name}: -webkit-calc(@calc);
  @{name}: -moz-calc(@calc);
  @{name}: calc(@calc);
}

Let's use our function:

styles.lessdiv {
  .calc(width, ~'10px + 30%');
}

Compilation result:

styles.cssdiv {
  width: -webkit-calc(10px + 30%);
  width: -moz-calc(10px + 30%);
  width: calc(10px + 30%);
}