title: LESSCSS - use calculation and return value
body: <p>H i,</p>
  
  <p>Hoping you can help.</p>
  
  <p>Is there a way for <strong>LESS</strong> to return just a value - <em>feel like I'm missing something very obvious</em></p>
  
  <p>Say I have:</p>
  
  <pre><code>@unit:em;
  @basevalue:1;
  </code></pre>
  
  <p>Can I use something to give me a shorthand return for -</p>
  
  <pre><code>.someClass {  padding: ~'@{basevalue}@{unit}'; }
  </code></pre>
  
  <p><em>Like say:</em> </p>
  
  <pre><code>.returnUnit() { ~'@{basevalue}@{unit}'; }
  
  .someClass {  padding: returnUnit(); }
  </code></pre>
  
  <p><strong>because what I'm ultimately hoping for is:</strong> </p>
  
  <pre><code>.returnUnit(@val) { @basevalue*@val@{unit}; }
  .someClass {  padding:returnUnit(0.5); }
  </code></pre>
  
  <hr>
  
  <p>Using a mixing I have to define the style property, however the value of this <em>return function</em> would be used for many different css properties.</p>
  
  <hr>
  
  <p>Hope I made sense and I am just lacking deeper rtfm.</p>
  
  <p>Many Thanks if you can.</p>
  
  <hr>
  
  <p><strong>Update</strong> as @Chococrocs <a href="http://lesscss.org/features/#mixins-as-functions-feature" rel="noreferrer">pointer to the docs</a>, thanks.</p>
  
  <pre><code>.average(@x, @y) {
    @average: ((@x + @y) / 2);
  }
  
  div {
    .average(16px, 50px); // "call" the mixin
    padding: @average;    // use its "return" value
  }
  </code></pre>
  
  <ul>
  <li>Looks like what I need ? - <em>just seeing if I can always tag on the unit variable to it....</em>
  <hr></li>
  </ul>
  
  <h2>Update: That gets part way ...</h2>
  
  <pre><code>.unitRelative(@val) {
    @value : @basevalue*@val;
    @relative: ~'@{value}@{unit}';
  }
  /* usage */
  
   .someClass { 
    .unitRelative(2);
    padding: @relative;
  }
  </code></pre>
  
  <p>But not when</p>
  
  <pre><code>.someClass {
      .unitRelative(2);
      padding:@relative;
      .unitRelative(3);
      margin:@relative;
  }
  </code></pre>
  
  <p>Is there another way ? </p>