On Sat, Jun 26, 2010 at 3:47 PM, P Kishor <[email protected]> wrote:
> On Sat, Jun 26, 2010 at 3:39 PM, Chris Marshall <[email protected]> wrote:
>> On 6/26/2010 1:55 PM, P Kishor wrote:
>>>
>>> a few days back I had asked for help creating an [x,y,z] dims piddle
>>> where every element was a random integer between 0 and 255. A couple
>>> of suggestions set me off to learn dummy(), and I also learned the
>>> correct use of random() (thanks, Daniel and Chris). Today, I figured
>>> out a way to make any dimension piddle filled with random integers
>>> between any two integers<max>  and<min>.
>>>
>>> $a = (( (zeroes(<dim>  [,<dim>  ..] ))->random * (<max>  -<min>  + 1
>>> )) +<min>  )->floor
>>>
>>> The thing is, the above works whether I use zeroes or ones, which, I
>>> am guessing is because internally PDL::new_from_specification is being
>>> used to create a template for the piddle.
>>
>> It will also work if you leave out the ones or zeros/zeroes and
>> put the type and dimension arguments in random:
>>
>> PDL>   $a = (random(5,5,3)*(1000-500+1)+500)->floor
>
> very nice, thanks! That said, I kinda like method calls on objects. I
> like $p->random more than random(), and for that reason, I have warmed
> to $p->slice more than the NiceSlice syntax. zeroes gives me a piddle
> to work on.
>
>..

ha! now that I have stared at the above, I realize that I was talking
nonsense. Your method is absolutely much better than mine because your
method requires less typing, hence, less chance of errors, and
produces just as good a result. zeroes() and random() are analogous.


-- 
Puneet Kishor

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to