Message Boards Message Boards

0
|
906 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

The variable name naming rules during the development of a package.

Posted 1 year ago

It's well known that in the process of developing a package or complex script writing and debugging, we need to have many custom variable names, such as the following code snippets:

In[1]:= "cGAP12 := [[-1, -1, 1, 3/4], [1, -1, -1, -5/4], [-1, 1, -1, \
-5/4], [0, 0, 0, 1]];" // 
   StringReplace[#, {"\n " -> "", "[" -> "{", "]" -> "}", ":=" -> "=",
       ";" -> ""}] & // ToExpression;
"lat12 := [[1, -1, -1], [1, 1, -1], [1, -1, 1]];" // 
   StringReplace[#, {"\n " -> "", "[" -> "{", "]" -> "}", ":=" -> "=",
       ";" -> ""}] & // ToExpression;
zeroTranLat12 = 
 AffineTransform[{lat12, {0, 0, 0}}] // TransformationMatrix

"cx := [ [ 0, 0, 1, 1/2 ], [ 0, 1, 0, 1/2 ], [ 1, -1, -1, -1/2 ], [ \
0, 0, 0, 1 ] ];" // 
   StringReplace[#, {"\n " -> "", "[" -> "{", "]" -> "}", 
      ":=" -> "=",
             ";" -> ""}] & // ToExpression;
c2 = cx . zeroTranLat12

Out[3]= {{1, -1, -1, 0}, {1, 1, -1, 0}, {1, -1, 1, 0}, {0, 0, 0, 1}}

Out[5]= {{1, -1, 1, 1/2}, {1, 1, -1, 1/2}, {-1, -1, -1, -(1/2)}, {0, 
  0, 0, 1}}

I'm still very confused about this question. Is there a rule of thumb on how I should better name these variables so that I can use them better?

Regards, Zhao

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

Group Abstract Group Abstract