Computer Science Canada

Quick question: What is # used for?

Author:  Timothy Willard [ Fri Jun 28, 2013 10:04 pm ]
Post subject:  Quick question: What is # used for?

I can't find it anywhere in the Turing reference (not saying it isn't there, just saying I don't know where to look for it). I know it is used in Turing for something, but I don't know what.
Can anyone help out here?

Author:  Tony [ Fri Jun 28, 2013 10:06 pm ]
Post subject:  RE:Quick question: What is # used for?

example?

Author:  Dreadnought [ Fri Jun 28, 2013 10:17 pm ]
Post subject:  Re: Quick question: What is # used for?

cheat

Author:  Timothy Willard [ Sat Jun 29, 2013 7:41 pm ]
Post subject:  Re: Quick question: What is # used for?

The location I found it was in this link:http://compsci.ca/v3/viewtopic.php?t=31463.
I do realize that in this situation is sets a base for the integers, but later on down the topic it seems to translate any variable into its hexadecimal representation. I originally knew nothing about it, but I did some research (and testing) after posting this topic so I now have a vague idea about #. I am still curious as to is limits, and when specifically I can use it (for example, is there anyway to get put to display in base 16? When I type put #"a" I get Turing's keycode for a, 97, but that is in base 10.) I only know what # does vaguely, and I am looking for more specific information.

Author:  Dreadnought [ Sat Jun 29, 2013 9:12 pm ]
Post subject:  Re: Quick question: What is # used for?

Timothy Willard wrote:

The location I found it was in this link:http://compsci.ca/v3/viewtopic.php?t=31463

OMG, someone was trying to learn from my code! I'm not sure if I should be honoured or ashamed (I did some messy stuff in that post).

As I posted earlier, # is a type cheat. (read the Turing documentation for "cheat" if you want to know as much as possible)

cheat converts the bit representation of one type into another. Ex: the character 'a' has the bit representation 1100001 which is the same as the integer (or natural number) 97

# is a short form which converts to the nat type. If we specify a base in front of #, like in the case of B#N, then # will produce the nat with representation N in base B.

So # does not convert to the hexadecimal representation, 16#<hex> evaluates to the nat with hexadecimal representation <hex>.


Also
Timothy Willard wrote:
is there anyway to get put to display in base 16?

Look up intstr and/or natstr.


: