Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » short-hand
short-hand [message #3415] Wed, 24 May 2006 12:04 Go to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
is there any short-hand for something like this:

Array<int> ints;
String str = "";

... - adds some elements to 'ints'

for(int q = -1; ++q < ints.GetCount(); ) {
    str += AsString(ints.[q]) + " ";
}


?

excluding
for(int q = -1; ++q < ints.GetCount(); str += AsString(ints.[q]) + " "); Surprised
Re: short-hand [message #3416 is a reply to message #3415] Wed, 24 May 2006 12:28 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

qwerty wrote on Wed, 24 May 2006 06:04

is there any short-hand for something like this:

Array<int> ints;
String str = "";

... - adds some elements to 'ints'

for(int q = -1; ++q < ints.GetCount(); ) {
    str += AsString(ints.[q]) + " ";
}


?

excluding
for(int q = -1; ++q < ints.GetCount(); str += AsString(ints.[q]) + " "); Surprised



1 char less... Smile

for(int q = -1; ++q < ints.GetCount(); str += AsString(ints[q]) + " "); 
for(int q = -1; ++q < ints.GetCount(); str += Format("%d ", ints[q])); 

[Updated on: Wed, 24 May 2006 12:30]

Report message to a moderator

Re: short-hand [message #3417 is a reply to message #3416] Wed, 24 May 2006 13:02 Go to previous messageGo to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
huh Smile, yeah, it's prettier!
Re: short-hand [message #3418 is a reply to message #3415] Wed, 24 May 2006 13:12 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
qwerty wrote on Wed, 24 May 2006 06:04

is there any short-hand for something like this:

Array<int> ints;
String str = "";

... - adds some elements to 'ints'

for(int q = -1; ++q < ints.GetCount(); ) {
    str += AsString(ints.[q]) + " ";
}


?

excluding
for(int q = -1; ++q < ints.GetCount(); str += AsString(ints.[q]) + " "); Surprised



Well, not much better, but

for(int q = 0; q < ints.GetCount(); i++) // you can keep your version here too, I like this better...
   str << ints[q] << ' ';


..as operator<< for Stream and String translates to calling AsString...

Not that using "<<" is also faster here (because you are adding to existing string, instead of concating and adding...)

Mirek
Re: short-hand [message #3419 is a reply to message #3418] Wed, 24 May 2006 13:55 Go to previous message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
Arigato! Smile


btw, I had on mind some pumping function, e.g.

pump(str, ints, ' ');
or something...

but it was just an idea.

[Updated on: Wed, 24 May 2006 14:04]

Report message to a moderator

Previous Topic: How Use Substring Search?
Next Topic: user 'Value' [FEATURE REQUEST]
Goto Forum:
  


Current Time: Wed May 08 07:35:30 CEST 2024

Total time taken to generate the page: 0.02587 seconds