I have a simple, general question regarding a real small issue that bothers me:
I’m printing a list of elements on the fly, so I don’t have prior knowledge about the number of printed elements. I want a simple format where the elements are separated by a comma (elem1, elem2…) or something similar. Now, if I use a simple loop like:
while(elements to check) {
if (elem should be printed) {
print elem . ","
}
}
I get a comma after the last element…
I know this sounds quite stupid, but is there a way to handle this?
Why not add a comma BEFORE each element (but the first one)? Pseudo-code: