Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Quick question: What is # used for?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Timothy Willard




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Tony




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

example?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Dreadnought




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

cheat
Timothy Willard




PostPosted: 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.
Dreadnought




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: