title: Writing a parameterless function in Ramda in a point free style?
body: <p>Consider the working code below:</p>
  <pre><code>var randN = x =&gt; () =&gt; Math.floor(x*Math.random());
  var rand10 = randN(10)
  times(rand10, 10) // =&gt; [6, 3, 7, 0, 9, 1, 7, 2, 6, 0]
  </code></pre>
  <p><code>randN</code> is a function that takes a number and returns an RNG that, when called, will return a random int in the range [0, N-1].  So it's a factory for specific RNGs.</p>
  <p>I've been using <a href="http://ramdajs.com/" rel="nofollow noreferrer">ramda.js</a>, and learning functional programming theory, and my question is: Is it possible to rewrite <code>randN</code> in a point free style using ramda?</p>
  <p>For example, I could write:</p>
  <pre><code>var badAttempt = pipe(multiply(Math.random()), Math.floor)
  </code></pre>
  <p>This would satisfy the &quot;point-free style&quot; requirement, but fails to behave the same way as <code>randN</code>: calling <code>badAttempt(10)</code> simply returns a single random number between 1 and 10, rather than a <em>function</em> that generates a random number between 1 and 10 when called.</p>
  <p>I have not been able to find a combination of ramda functions that enables me to do the rewrite in a point-free style.  I can't tell if this is just a failure on my part, or something special about using <code>random</code>, which breaks referential transparency and therefore may be incompatible with a point free style.</p>
  <h2>update</h2>
  <p>my own slight variation on the solution, after discussing it with Denys:</p>
  <pre><code>randN = pipe(always, of, append(Math.random), useWith(pipe(multiply, Math.floor)), partial(__,[1,1]))
  </code></pre>