Re: functions: rotate and factorial

2008-03-17 Thread Chas. Owens
On Mon, Mar 17, 2008 at 10:34 AM, Sharan Basappa <[EMAIL PROTECTED]> wrote: > Rob, > > Actually you are correct. I was on my way to implement permutation for > a given set of numbers. > In that context, I had designed my own algo as a part of bigger > problem I am trying to solve. > That algo

Re: functions: rotate and factorial

2008-03-17 Thread Sharan Basappa
Rob, Actually you are correct. I was on my way to implement permutation for a given set of numbers. In that context, I had designed my own algo as a part of bigger problem I am trying to solve. That algo requires rotate and factorial. Rotate to get different combinations and factorial to limit for

Re: functions: rotate and factorial

2008-03-14 Thread Rob Dixon
Sharan Basappa wrote: > Thanks everybody. I need to use these as a part of algo I am working on. I will get back if I have any comments .. Rotating an array and calculating a factorial are both likely to absorb large amounts of processor time unless your problem is trivial. I'm also intrigued t

Re: functions: rotate and factorial

2008-03-14 Thread Sharan Basappa
Thu, 13 Mar 2008 18:06:27 +0530 > > From: "Sharan Basappa" <[EMAIL PROTECTED]> > > To: beginners@perl.org > > Subject:functions: rotate and factorial > > > > > > &

Re: functions: rotate and factorial

2008-03-13 Thread obdulio santana
2008/3/13, Jenda Krynicky <[EMAIL PROTECTED]>: > > Date sent: Thu, 13 Mar 2008 18:06:27 +0530 > From: "Sharan Basappa" <[EMAIL PROTECTED]> > To: beginners@perl.org > Subject: functions: rotate an

Re: functions: rotate and factorial

2008-03-13 Thread Chas. Owens
On Thu, Mar 13, 2008 at 9:02 AM, Jenda Krynicky <[EMAIL PROTECTED]> wrote: snip > right > @a = (pop(@a), @a); > > left > @a = (@a[1..$#a], $a[0]); snip These are O(n) operations and are fine if n is small, but the push/shift and unshift/pop implementations are O(1). Of course, the push/shift

Re: functions: rotate and factorial

2008-03-13 Thread Jenda Krynicky
Date sent: Thu, 13 Mar 2008 18:06:27 +0530 From: "Sharan Basappa" <[EMAIL PROTECTED]> To: beginners@perl.org Subject: functions: rotate and factorial > Hi, > > I was wondering if perl has support for t

Re: functions: rotate and factorial

2008-03-13 Thread Chas. Owens
On Thu, Mar 13, 2008 at 8:36 AM, Sharan Basappa <[EMAIL PROTECTED]> wrote: snip > - rotate: the elements of a given array are shifted such the elements > are shifted right or left > and the last/first element fill the first/last position depending on > whether shift right or shift left is > do

functions: rotate and factorial

2008-03-13 Thread Sharan Basappa
Hi, I was wondering if perl has support for the following operators or functions: - rotate: the elements of a given array are shifted such the elements are shifted right or left and the last/first element fill the first/last position depending on whether shift right or shift left is done. - fact