473,388 Members | 1,286 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Inefficient? but fun. :-)

public static IEnumerable<TRotateLeft<T>(IEnumerable<T>
collection)
{
using (IEnumerator<Tvalues = collection.GetEnumerator())
{
if (values.MoveNext())
{
T last = values.Current;
while (values.MoveNext())
{
yield return values.Current;
}
yield return last;
}
}
}
public static IEnumerable<TRotateLeft<T>(IEnumerable<Tcollection ,
int toTheLeft)
{
if (toTheLeft < 0)
{
throw new ArgumentException("No negatives please");
}
IEnumerable<Tresult = collection;
for (int i = 0; i != toTheLeft; ++i)
{
result = RotateLeft<T>(result);
}
return result;
}
Feb 25 '08 #1
0 774

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Stefan Berglund | last post by:
I've noticed that most examples offered in this group tend to use Response.Write to spit out the HTML rather than switch between script and HTML. I also came across an article intimating the same...
1
by: Mike Ridley | last post by:
Suppose I have a customer table ("customer"):- Primary Key cust_id long integer cust_name text(40) cust_type text(1) containing 80000 rows. There are about 10000 rows where customer type =...
9
by: Javaman59 | last post by:
Using local declarations within a block often makes code more readable, but is it less efficient? eg... void P() { while (...) { int i = ...; bool b = ...; .... } }
17
by: News | last post by:
Hi everyone, My goal is to pull command switches/options from a file and then assign the values to select variables which would eventually be included in a class object. The data file looks...
1
by: Kourosh | last post by:
I have a big loop that checks the value of a checkbox several times (1000+ times) I'm just wondering, would it be any more efficient to save the value of the checkbox outside the loop and the read...
6
by: ImOk | last post by:
I am using Windows IIS with PHP5 CGI. When I want to use an extension in PHP5 under Windows I enable the extension line in PHP.INI. (e.g. extension=php_sqlite.dll). Does PHP load all the...
8
by: Bryan | last post by:
I want my business objects to be able to do this: class Person(base): def __init__(self): self.name = None @base.validator def validate_name(self): if not self.name: return
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.