Talk:Trimming (computer programming)

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Computer science  
WikiProject icon This article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
 ???  This article has not yet received a rating on the project's quality scale.
 ???  This article has not yet received a rating on the project's importance scale.

C/C++ example needs actual code[edit]

The C/C++ example isn't too illustrative of the theory behind trimming a string in C. Perhaps an example that contains the actual code would be more appropriate. (I want to see some loops in there!) --indil 20:55, 19 July 2006 (UTC)

I went for a brief overview and stuck with the simplest functions/libraries/implementations I could find. Please feel free to add some code :) —Pengo talk · contribs 13:02, 23 July 2006 (UTC)
I've changed the code for the C example. I believe the old example would have leaked memory - for processing large amounts of data, this could cause problems! On a side note, could someone check to make sure I haven't done something dumb while writing this (it compiled and worked in VC++) --Portej 07:29, 26 September 2007 (UTC)
At least for me the example in C does NOT work. i doubled checked it, but still believe, that i did not make a mistake. the problematic section is shown below. this causes a segmentation fault in my environment (gcc-4.1.3). --Alex.blackbit 18:32, 1 November 2007 (UTC)
if (last != input)
    last[1] = 0;
Alex, this is with strings that don't need trimming? Yeh, last should have been initialized with ret before the loop. I'm fine with just dropping the code though, if it wasn't just a line count thing. James Antill 16:03, 6 November 2007 (UTC)

in AWK better to use those command:

function ltrim(s) { sub(/^ */, "", s); return s }

function rtrim(s) { sub(/ *$/, "", s); return s }

function trim(s) { return rtrim(ltrim(s)); }

Keep the functions. Remove just code[edit]

Hi, I think you should remove the "other languages which don't have trim functions" section. They don't have trim or a close analogue, so they should be trimmed. It is superfluous text at the end of the article that happens to take up more than half the article that is supposed to be on trim rather than what is not trim. It is quite easy to define trim-like and, by omision what is not trim-like. That section becomes a tutorial on how to write trim in other languages and should be removed or moved to this talk page. Please refer to this. --Paddy 05:32, 10 October 2007 (UTC)

It's about trim library functions as well as trim algorithms. Most of the examples (except C) are only one or two lines of code (which is probably why they don't have library functions). Hardly a hand-holding instruction manual. Leaving them out is to pretend trimming isn't used in these languages, and removes much of the language-specific discussion. Lastly, the code certainly doesn't belong on the talk page. —Pengo 14:26, 10 October 2007 (UTC)
I see what you mean about the short examples, and also not transferring them to the talk pages, but that large chunk of C? Surely that should go. --Paddy 15:32, 10 October 2007 (UTC)
Yep, probably. Would be nice to move it to Wikibooks, or at least include a link to an open source implementation of the same thing though. —Pengo 06:09, 11 October 2007 (UTC)
The only point is that if that trim function was used on a large dataset, with lots of whitespace, it would leak memory at a heck of a rate. Is there anywhere that implementations can go? (someone mentioned wikibooks) —Preceding unsigned comment added by (talk) 14:37, 17 October 2007 (UTC)
I dropped the line count significantly on the C example, and it now doesn't allocate memory. Both of which make it much more likely to resemble a real implementation IMO. --James Antill 05:32, 19 October 2007 (UTC)
Thanks, it is more succinct, but the point remains that the C function is showing how to write trim in C which does not have trim. Best to leave it out and rely on the mention of external libraries that give trim functionality as a package. --Paddy 18:04, 19 October 2007 (UTC)
I've re-removed the C function, as it seems to be a perennial problem. The other code in the article is well established and used frequently in copy/paste programming. I don't think Wikipedia is the best environment to write new code. It could even be seen as "original research". —Pengo 01:08, 2 November 2007 (UTC)

SAS has a trimmed TRIM[edit]

the SAS language has a STRIP function, but this only removes the space (ASCII 0x20) characters, not all whitespace. —Preceding unsigned comment added by (talk) 14:32, 8 February 2011 (UTC)

External links modified[edit]

Hello fellow Wikipedians,

I have just added archive links to one external link on Trimming (computer programming). Please take a moment to review my edit. If necessary, add {{cbignore}} after the link to keep me from modifying it. Alternatively, you can add {{nobots|deny=InternetArchiveBot}} to keep me off the page altogether. I made the following changes:

When you have finished reviewing my changes, please set the checked parameter below to true to let others know.

You may set the |checked=, on this template, to true or failed to let other editors know you reviewed the change. If you find any errors, please use the tools below to fix them or call an editor by setting |needhelp= to your help request.

  • If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
  • If you found an error with any archives or the URLs themselves, you can fix them with this tool.

If you are unable to use these tools, you may set |needhelp=<your help request> on this template to request help from an experienced user. Please include details about your problem, to help other editors.

Cheers.—cyberbot IITalk to my owner:Online 07:23, 15 January 2016 (UTC)