Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Mathematica - General Programming style' topicStudent Support Forum > General > Archives > "Mathematica - General Programming style"

Next Comment >Help | Reply To Topic
Author Comment/Response
speleomania
04/23/13 1:13pm

Hi,

I could use some advice on this

I often find myself writing code similar to this:

dwg = StringSplit[ToUpperCase[Import[#]], "\n"];
dwg = List[StringJoin[Riffle[StringSplit[#] // Most, " "]],
StringSplit[#] // Last] & /@ dwg;
dwg = Select[dwg, ! StringMatchQ[#[[1]], "*|*"] &];
dwg = Intersection[dwg, templatecolors,
SameTest -> ((#1 // First) == (#2 // First) &)];
Complement[dwg, templatecolors] // TableForm


I'm looking at the multiple dwg = assignment and I'm wondering if there's a better way to organize my code. I know that all the above lines can be merged together in one single giant math code line, but for sake of readability I'd like to keep the lines separate /as they are/ because I can more easily keep track of what's going on on each line and it's also much easier to debug

so - how would you reorganize code such as this one?

Thanks


URL: ,

Subject (listing for 'Mathematica - General Programming style')
Author Date Posted
Mathematica - General Programming style speleomania 04/23/13 1:13pm
Re: Mathematica - General Programming style Bill Simpson 04/23/13 3:53pm
Re: Re: Mathematica - General Programming style speleomania 04/24/13 4:10pm
Re: Re: Re: Mathematica - General Programming s... Bill Simpson 04/24/13 9:49pm
Re: Mathematica - General Programming style hieron 04/23/13 6:18pm
Re: Re: Mathematica - General Programming style speleomania 04/24/13 4:14pm
Next Comment >Help | Reply To Topic