user660084
user660084

Reputation: 11

How would this code segment look as pseudo-code?

I have this code:

for(iteration<string> it=name_list.iterator();it.hasNext();)

What would be a suitable pseudo-code representation for the above code?

Upvotes: 1

Views: 1174

Answers (3)

paxdiablo
paxdiablo

Reputation: 881353

Since pseudo-code is meant to be more human-readable, I'd simply opt for something like:

for each name in name_list:
    do something with name

You shouldn't have any need to put implementation details like iterators in your pseudo-code, rather you should simply specify intent. And I find the Python style of coding suits this sort of thing perfectly.

You should also use more descriptive names than it. I'm assuming that's for iterator but it gives absolutely no indication as to what the variable is. This is something you should aim for not just in pseudo-code but in real code as well.

Upvotes: 2

Robert Levy
Robert Levy

Reputation: 29073

"For each item in name_list" at least that's probably the intention. This code on its own is just an infinite loop though because it never moves the iterator

Upvotes: 0

corsiKa
corsiKa

Reputation: 82559

The easiest way to make real code into pseudocode is to screw it up. :-) mwahahaha!

That could turn into

for each iteration of name_list.iterator as it

It could turn into hundreds of others too!

Upvotes: 0

Related Questions