Editing 1537: Types
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 33: | Line 33: | ||
# <code>2+2</code> would normally be <code>4</code>. However, the interpreter takes this instruction to mean that the user wishes to increase the actual value of the number <code>2</code> (aka the "literal value") by <code>2</code> for the remainder of the program, making it <code>4</code> and then reports that the work is "Done". The result can be seen in the subsequent lines where all <code>2</code>s are replaced by <code>4</code>s. This could be a reference to languages like Fortran where [http://everything2.com/title/Changing+the+value+of+5+in+FORTRAN literals could be assigned new values]. This would normally be <code>2+=2</code>. | # <code>2+2</code> would normally be <code>4</code>. However, the interpreter takes this instruction to mean that the user wishes to increase the actual value of the number <code>2</code> (aka the "literal value") by <code>2</code> for the remainder of the program, making it <code>4</code> and then reports that the work is "Done". The result can be seen in the subsequent lines where all <code>2</code>s are replaced by <code>4</code>s. This could be a reference to languages like Fortran where [http://everything2.com/title/Changing+the+value+of+5+in+FORTRAN literals could be assigned new values]. This would normally be <code>2+=2</code>. | ||
#<code>RANGE(1,5)</code> would normally return <code>(1,2,3,4,5)</code>; however, because the value of <code>2</code> has been changed to <code>4</code>, it returns <code>(1,4,3,4,5)</code>. This also affects the line number by changing the "2" in 12 to "4" resulting in the line number 14. | #<code>RANGE(1,5)</code> would normally return <code>(1,2,3,4,5)</code>; however, because the value of <code>2</code> has been changed to <code>4</code>, it returns <code>(1,4,3,4,5)</code>. This also affects the line number by changing the "2" in 12 to "4" resulting in the line number 14. | ||
β | #<code>FLOOR(10.5)</code> should return <code>10</code> (the "floor" of a decimal number is that number rounded down); however, it instead returns {{w|ASCII art}} of the number on a "floor." | + | #<code>FLOOR(10.5)</code> should return <code>10</code> (the "floor" of a decimal number is that number rounded down); however, it instead returns {{w|ASCII art}} of the number on a "floor." |
The title text contains three further examples relating to color. <code>color.rgb("blue")</code> returns the hexadecimal code for pure blue (as would be used in HTML, for example), which is how a real programming language might work. The lookup for "yellowish blue" returns "NaN" (Not a Number) again, which makes sense at one level because there is no such color as "yellowish blue" (yellow and blue are opposites on the RGB {{w|color triangle}}, making yellowish-blue an {{w|impossible colour}}, which can only be perceived with great difficulty through contrived figures). However a more typical result would have been a failure indicating that the color database does not include the name, in the same way that a typo such as "bluw" would. (Note that HTML does [http://stackoverflow.com/q/8318911/256431 explicitly attempt] to handle all "color names", though unrecognized ones like "yellowish blue" just interprets them as numbers (with zeros replacing invalid hexadecimal digits). For the record, "yellowish blue" is a dark blue with an imperceptible amount of red β <code style='background-color: #0e00b0; color: white'>#0E00B0</code>.) Similarly sorting the colors would normally produce some defined ordering, such as alphabetical, but in this language it generates the string "rainbow". It seems that Randall's new language understands color theory in an unusually deep way. | The title text contains three further examples relating to color. <code>color.rgb("blue")</code> returns the hexadecimal code for pure blue (as would be used in HTML, for example), which is how a real programming language might work. The lookup for "yellowish blue" returns "NaN" (Not a Number) again, which makes sense at one level because there is no such color as "yellowish blue" (yellow and blue are opposites on the RGB {{w|color triangle}}, making yellowish-blue an {{w|impossible colour}}, which can only be perceived with great difficulty through contrived figures). However a more typical result would have been a failure indicating that the color database does not include the name, in the same way that a typo such as "bluw" would. (Note that HTML does [http://stackoverflow.com/q/8318911/256431 explicitly attempt] to handle all "color names", though unrecognized ones like "yellowish blue" just interprets them as numbers (with zeros replacing invalid hexadecimal digits). For the record, "yellowish blue" is a dark blue with an imperceptible amount of red β <code style='background-color: #0e00b0; color: white'>#0E00B0</code>.) Similarly sorting the colors would normally produce some defined ordering, such as alphabetical, but in this language it generates the string "rainbow". It seems that Randall's new language understands color theory in an unusually deep way. |