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

Username:   Password: 
 RegisterRegister   
 Please Help Me
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tmanfromtoronto




PostPosted: Mon Oct 29, 2012 10:05 am   Post subject: Please Help Me

Hi guys! I need some help with this. How do I write a program that only outputs the first and last letter of every word? Thank You
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Mon Oct 29, 2012 10:26 am   Post subject: RE:Please Help Me

Look up 'substring' in the Turing documentation.
mirhagk




PostPosted: Mon Oct 29, 2012 3:09 pm   Post subject: RE:Please Help Me

actually with the first and last letter you should use indexing with the string. Look into arrays, and it's the same with strings (which are actually arrays of characters).

ie
Turing:
name := "mirhagk"
put name(0)
put name(1)


would print out:
code:

m
i

I'll leave it to you to figure out how to get the last character, but look for something where you can get how long the string it.
Aange10




PostPosted: Mon Oct 29, 2012 3:23 pm   Post subject: RE:Please Help Me

Actually in turing a string followed by (0) (such as:

Turing:

put name(0)
)

is an error. It Starts at one.



Also, typing in
Turing:

length(name)

will tell you what position the last character is in.
mirhagk




PostPosted: Mon Oct 29, 2012 3:30 pm   Post subject: RE:Please Help Me

ah sorry about that. Keep mixing turing syntax with other languages.
Insectoid




PostPosted: Tue Oct 30, 2012 2:01 pm   Post subject: RE:Please Help Me

Quote:
actually with the first and last letter you should use indexing with the string.


I suggest you too look up substring in the Turing docs, Mirhagk.
QuantumPhysics




PostPosted: Tue Oct 30, 2012 3:50 pm   Post subject: RE:Please Help Me

As I see it, turing is very efficient. Just enter the help docs -> index -> Type in "string" and search the string library, you can learn the most if you do it by yourself. Isn't that what computer science is all about? Discovery.
RE: Some of the worlds best programmers/scripters learned on their own, the rest are just little sheep following the herd. If you don't learn by yourself then you will not learn at all. It should be a life lesson. If all else fails -> Return for help.
chipanpriest




PostPosted: Wed Oct 31, 2012 7:17 pm   Post subject: Re: Please Help Me

Say your word is "rickgrimes", do this:

Turing:

put "rickgrimes" (1) ..
put "rickgrimes" (length ("rickgrimes") - 1)


Your program would display:
rs
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: