STL bind1st counterpart for unary function

From: Fred Ma (fma_at_doe.carleton.ca)
Date: 02/05/04


Date: 5 Feb 2004 09:33:46 GMT

Hello,

I have a random generator that takes a scaling factor as an
argument. Since it takes one argument, it is not a
generator in the sense defined by SGI's online STL
documentation. I'd like to use this as a generator in the
STL algorithm "generate". I know I have to change random
generator from its current implementation to make it
adaptable. But unlike the bind1st adapter, there isn't any
premade function adapter that reduces the arity of a unary
function by binding the argument to a constant. So I can't
use it in the STL generate algorithm without writing a
wrapper. It's not a big deal, but it's a bit of a waste to
write a wrapper just to fix the argument of the generator to
one constant value, and just to avoid rolling my own loop to
fill a container with random numbers. Of course I will
write my own one-line loop, but just out pedagogical
curiosity, is there a _simple_ way to use the STL generate
algorithm in this case, using only standardized libraries?

Fred

-- 
Fred Ma
Dept. of Electronics, Carleton University
1125 Colonel By Drive, Ottawa, Ontario
Canada, K1S 5B6


Relevant Pages

  • Re: Random reordering of a list
    ... On Sun, 7 Nov 2004, Top Spin wrote: ... > number generator, will the following algorithm do the job? ... > Loop through the list. ...
    (sci.stat.math)
  • Random reordering of a list
    ... If I need to shuffle a list of numbers and I have a decent random ... number generator, will the following algorithm do the job? ... Loop through the list. ...
    (sci.stat.math)
  • Re: Agduria dungeon generation
    ... stage of the algorithm and rise appropriate error, ... A NTAE generator doesn't have to have any ... NTAE will happily accept all valid inputs and RNG states and produce ...
    (rec.games.roguelike.development)
  • Re: Math.random
    ... That's not the only possible algorithm; ... without much difficulty implement a long shift-register generator; ... doublevalue or null/undefined/false for auto reseeding, ... I think 0 to 364 would be better; it goes well with zero-based arrays, ...
    (comp.lang.javascript)
  • Re: real random
    ... Feel free to post such an algorithm, ... it as a generator of a stream of numbers, ... You need a genuine source of entropy, ... By suggesting Fortuna (which gathers genuine entropy as it goes), ...
    (comp.lang.c)