<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div>Thanks. I'll try to start with the indexing table for each character first. <br>Anyway do you know how to split string based on more than 1 character, for example I want to split string based on some punctuation. I have tried using tokenBasedOn, but still can not figured out how to use it for more than 1 separator. <br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;">----- Original Message ----<br>From: Cédrick Béler <cdrick65@gmail.com><br>To: A friendly place to get answers to even the most basic questions about Squeak. <beginners@lists.squeakfoundation.org><br>Sent: Wednesday, September 24, 2008 40:44 PM<br>Subject: Re: [Newbies] Collection in Smalltalk<br><br>
Hi,<br><br>As a start you can do:<br><br>alphabet := $a to: $z.<br>coll indexOf: $c returns 4<br><br>to have both upper and lower case:<br>alphabet indexOf: yourCaracter asLowercase<br><br>then you iterate on your string collection and add each result...<br><br>not sure about the $ word, but it could be once you detect the sum to be 100...<br><br>hth :)<br><br>Cédrick<br><br><br>but maybe you could reverse the collection so as to have ($a -> 1 ...<br> $z -> 26)<br><br>2008/9/24 Alex Chi <<a ymailto="mailto:alex_chi99@yahoo.com" href="mailto:alex_chi99@yahoo.com">alex_chi99@yahoo.com</a>>:<br>> Hi guys,<br>><br>> I am just beginner in Smaltalk and I have some problem with collection in<br>> smalltalk.<br>> For this problem I have to define the value of an alphabetic character based<br>> on its location in the alphabet. So 'a' and 'A' each have value 1, 'b' and<br>> 'B' each have 2, etc.
Non-alphabetic characters can be considered to have<br>> value 0.<br>> The value of a word is the sum of the value of all its characters. So<br>> 'Smalltalk' has value 101 and 'abc' has value 6.<br>> A dollar word is a word whose value is 100. I want to add a method to the<br>> String class that returns all the dollar words in the string.<br>><br>> So for example if the input is 'SmallTalk' the result is ('SmallTlk'<br>> 'SmllTlk').<br>><br>> Please kindly help me guys. Really appreciate your help.<br>><br>> Thanks.<br>><br>><br>> _______________________________________________<br>> Beginners mailing list<br>> <a ymailto="mailto:Beginners@lists.squeakfoundation.org" href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a><br>> <a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners"
target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br>><br>><br><br><br><br>-- <br>Cédrick<br></div></div></div><br>
</body></html>