tag:blogger.com,1999:blog-4212150079314071223.post7187740353487091439..comments2024-03-26T08:13:05.514+01:00Comments on Creative Scratchpad: Get heaviest objectsSwordslayerhttp://www.blogger.com/profile/09124250713006663760noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-4212150079314071223.post-30864278640189561272011-04-20T11:12:40.834+02:002011-04-20T11:12:40.834+02:00Hi, the "#" values are names and their s...Hi, the "#" values are names and their sole purpose is to be used as optional switches. I could have just as well used integers from one to three but this way it's a bit more descriptive when included in a bigger piece of code.<br /><br />The ":" is a part of case/of expression. Used like this when passed a large collection of nodes, it is actually a sub-optimal way of dealing with the task as for each iteration the script asks for a value of result_type and compares it to predefined set of labels. For that case I could have made a function getVal like this<br /><br /> local getVal = case result_type of<br /> (<br /> #objects : fn getVal node = node.obj<br /> #names : fn getVal node = node.obj.name<br /> #numbers : fn getVal node = node.facecount<br /> default : fn getVal node = node<br /> )<br /><br />and output the result this way:<br /><br /> result = for item = 1 to n where geom_arr[item] != undefined collect getVal geom_arr[item]<br /><br />Of course the "result" variable is unnecessary in both cases, it's there only to increase code readability.<br /><br />As for the code box, I'm glad you like. I edited the template to add some styling to pre and code tags, the syntax coloring is done by exporting as html from ConTEXT. If I wasn't so lazy I could have made a custom brush for SyntaxHighlighter and use that instead.<br /><br />EDIT: noticed some glitches with the embedded comment box, switched to pop-up instead...Swordslayerhttps://www.blogger.com/profile/09124250713006663760noreply@blogger.comtag:blogger.com,1999:blog-4212150079314071223.post-70048104974545153352011-04-20T04:04:05.357+02:002011-04-20T04:04:05.357+02:00Lines 24-27:
I don't fully understand.
The use...Lines 24-27:<br />I don't fully understand.<br />The use of "#" and ":" here confuse me.<br />Could you explain how that works, or point me<br />to some documentation?<br /><br />Also: Your code display is incredible.<br />Where did you come across that?PolygonRunnerhttps://www.blogger.com/profile/15934787628195946782noreply@blogger.com