Computer Science Canada

Please Help Me

Author:  Tmanfromtoronto [ 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

Author:  Insectoid [ Mon Oct 29, 2012 10:26 am ]
Post subject:  RE:Please Help Me

Look up 'substring' in the Turing documentation.

Author:  mirhagk [ 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.

Author:  Aange10 [ 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.

Author:  mirhagk [ Mon Oct 29, 2012 3:30 pm ]
Post subject:  RE:Please Help Me

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

Author:  Insectoid [ 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.

Author:  QuantumPhysics [ 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.

Author:  chipanpriest [ 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


: