Jump to content

Talk:Trimming (computer programming)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Pengo (talk | contribs) at 06:09, 11 October 2007 (yep.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

C/C++ example needs actual code

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)[reply]

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)[reply]
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)[reply]

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

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)[reply]

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)[reply]
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)[reply]
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)[reply]