I have glanced at the correspondance and the code. "Any suggestions on how to do it differently in J? "
To say a few words: You can of course do it like you do. I would say it is programming in C in J and nothing wrong with that if that is what you want. I would do it differently. - not define and do everything in one verb. - possibly one verb init to define globals - not do the ifs or at least not so complicated if structures - one or more verbs to do each scanning - one verb for the output - do the testing line by line in the script and once done you have the code for the whole operation When you work like that the code will begin to look different. - Björn Helgason gsm:6985532 skype:gosiminn On 11.1.2014 20:41, "Joe Bogner" <[email protected]> wrote: > I have about 300 code files (javascript and embedded code) that I want > to collect some metrics on. I've written the algorithm using an > imperative style. I actually wrote it first in C# and translated to J > > Here is the code (posted a link for brevity): > > J version: > https://gist.github.com/joebo/936ca5e2017c0a3b5c56 > > C# version: > https://gist.github.com/joebo/e7f8e3ca7bd21117e58d > > This is what it outputs > > calc'' > blocks 3 > max depth 2 > max block 113 > scripts 2 > max script 26 > > Any suggestions on how to do it differently in J? I looked into the > sequential machine some but couldn't figure out how to make it work > (if it could) since my approach required knowledge of the brace depth. > > In terms of requirements: > 1. Take a block of text > 2. Identify the code blocks in the file (start with @{ and end with } ) > 3. Count the code blocks > 4. Determine the max depth of the code block > 5. Determine the max size of all the code blocks > 6. Count the javascript blocks > 7. Determine the max size of the javascript block > > Thanks for any feedback or input! > > Joe > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
