Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.1K Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Counting words in a string of a list of string using a Do loop.

Posted 10 years ago
POSTED BY: Stefan S
5 Replies
Posted 10 years ago
POSTED BY: David Keith
Posted 10 years ago

Thanks David also for your solution.

Although this always splits the string in four "words" (or at least this sees to me). And at one stage I want to read also the "ic=" word. Anyhow it looks also very easy. I will give a try as well to see what fits me best.

The table representations looks very informative (and clearly shows that it is Spice file ;) )

Regards,

Stefan

POSTED BY: Stefan S
Posted 10 years ago

Hi Stefan, you are right about it splitting into at most 4 words. I did that because I recognized the Spice format. Parsing that 4th word is more complicated. For example Pulse( . . . ) must be recognized as a source spec, with the required argument list, and can't be just parsed at spaces until you've decided that the what is in ( . . ) is the argument list. Although you could eliminate the limit of 4 words, and then handle the split string. You could in fact add "(" and ")" to the list of delimiters and wind up with "Pulse" and 7 following arguments. (This is also a good example of a convenient truth: In Mathematica, there is almost always a better solution than a procedural loop.)

Best, David

POSTED BY: David Keith
Posted 10 years ago
POSTED BY: Sandu Ursu
Posted 10 years ago

Dear Sandu

It was just the semicolon! All the weekend reading without finding the answer. Must I end all lines with a semicolon within a loop?

I thought that if you end a command with semicolon it doesn't show an output and this was the reason for omitting it in the loop, but I was wrong.

I will also try the more concise solution you propose.

Thank you, Stefan

POSTED BY: Stefan S
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard