SmallTalk Collection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

SmallTalk Collection

4l3x
Hi guys,

I am just beginner in Smaltalk and I have some problem with collection in smalltalk.
For this problem I have to define the value of an alphabetic character based on its location in the alphabet. So ‘a’ and  ‘A’ each have value 1, ‘b’ and ‘B’ each have 2, etc. Non-alphabetic characters can be considered to have value 0.
The value of a word is the sum of the value of all its characters. So ‘Smalltalk’ has value 101 and ‘abc’ has value 6.
A dollar word is a word whose value is 100.  I want to add a method to the String class that returns all the dollar words in the string.

So for example if the input is 'SmallTalk' the result is ('SmallTlk' 'SmllTlk').

Please kindly help me guys. Really appreciate your help.

Thanks.
     
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] SmallTalk Collection

Terry Raymond
This is obviously a class problem and the members here
are not inclined to provide answers to class problem.
However, you can get help here. But, you need to break
down the problem yourself and ask specific questions.

Terry
 
===========================================================
Terry Raymond
Crafted Smalltalk
80 Lazywood Ln.
Tiverton, RI  02878
(401) 624-4517      [hidden email]
<http://www.craftedsmalltalk.com>
===========================================================

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of 4l3x
> Sent: Wednesday, September 24, 2008 4:11 PM
> To: [hidden email]
> Subject: [vwnc] SmallTalk Collection
>
>
> Hi guys,
>
> I am just beginner in Smaltalk and I have some problem with collection in
> smalltalk.
> For this problem I have to define the value of an alphabetic character based
> on its location in the alphabet. So 'a' and  'A' each have value 1, 'b' and
> 'B' each have 2, etc. Non-alphabetic characters can be considered to have
> value 0.
> The value of a word is the sum of the value of all its characters. So
> 'Smalltalk' has value 101 and 'abc' has value 6.
> A dollar word is a word whose value is 100.  I want to add a method to the
> String class that returns all the dollar words in the string.
>
> So for example if the input is 'SmallTalk' the result is ('SmallTlk'
> 'SmllTlk').
>
> Please kindly help me guys. Really appreciate your help.
>
> Thanks.
>
> --
> View this message in context: http://www.nabble.com/SmallTalk-Collection-tp19656916p19656916.html
> Sent from the VisualWorks mailing list archive at Nabble.com.
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] SmallTalk Collection

nic-19
In reply to this post by 4l3x
Hi,

Terry is right that is more a "class" problem, but for fun:

str := 'Smalltalk'.
sum := str sum: [:c |   (c isAlphabetic  ifTrue: [c asLowercase
asInteger - 96 ] ifFalse: [0])].
^sum

You can run the code in a  Workspace.

Success ..
Nic

4l3x wrote:

> Hi guys,
>
> I am just beginner in Smaltalk and I have some problem with collection in
> smalltalk.
> For this problem I have to define the value of an alphabetic character based
> on its location in the alphabet. So ‘a’ and  ‘A’ each have value 1, ‘b’ and
> ‘B’ each have 2, etc. Non-alphabetic characters can be considered to have
> value 0.
> The value of a word is the sum of the value of all its characters. So
> ‘Smalltalk’ has value 101 and ‘abc’ has value 6.
> A dollar word is a word whose value is 100.  I want to add a method to the
> String class that returns all the dollar words in the string.
>
> So for example if the input is 'SmallTalk' the result is ('SmallTlk'
> 'SmllTlk').
>
> Please kindly help me guys. Really appreciate your help.
>
> Thanks.
>      
>  

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] SmallTalk Collection

Steffen Märcker
In reply to this post by 4l3x
As far as I've understood the taks I've written a simple recursive solution. Source is attached.
Is this what you're looking for?

Steffen
____________________________________________________________________
Psssst! Schon vom neuen WEB.DE MultiMessenger gehört?
Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] SmallTalk Collection

Roger Whitney
In reply to this post by 4l3x
This is one of my students asking about a class assignment. The  
statement of the problem below is incorrect. I direct the student to  
the class wiki (http://www.eli.sdsu.edu/cgi-bin/wiki/page.ssp?wikiname=CS535&pagename=Questions+about+Assignment+3 
) where there is more information about that problem. I do have office  
hours before class today (4:15-5:15 pm) and later in the evening  
(8:30-9:30 pm). The student should make use of one of those times to  
talk to me so that they understand the problem correctly. I will talk  
to my class today about inappropriateness of using this mailing list  
to ask for solutions to homework problems.


>
>
> Hi guys,
>
> I am just beginner in Smaltalk and I have some problem with  
> collection in
> smalltalk.
> For this problem I have to define the value of an alphabetic  
> character based
> on its location in the alphabet. So ?a? and  ?A? each have value 1, ?
> b? and
> ?B? each have 2, etc. Non-alphabetic characters can be considered to  
> have
> value 0.
> The value of a word is the sum of the value of all its characters. So
> ?Smalltalk? has value 101 and ?abc? has value 6.
> A dollar word is a word whose value is 100.  I want to add a method  
> to the
> String class that returns all the dollar words in the string.
>
> So for example if the input is 'SmallTalk' the result is ('SmallTlk'
> 'SmllTlk').
>
> Please kindly help me guys. Really appreciate your help.
>
> Thanks.
>



----
Roger Whitney              Department of Computer Science
[hidden email]        San Diego State University
http://www.eli.sdsu.edu/   San Diego, CA 92182-7720


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] SmallTalk Collection

Travis Griggs-3
On Sep 25, 2008, at 8:31 AM, Roger Whitney wrote:

> This is one of my students asking about a class assignment. The
> statement of the problem below is incorrect. I direct the student to
> the class wiki (http://www.eli.sdsu.edu/cgi-bin/wiki/page.ssp?wikiname=CS535&pagename=Questions+about+Assignment+3
> ) where there is more information about that problem. I do have office
> hours before class today (4:15-5:15 pm) and later in the evening
> (8:30-9:30 pm). The student should make use of one of those times to
> talk to me so that they understand the problem correctly. I will talk
> to my class today about inappropriateness of using this mailing list
> to ask for solutions to homework problems.


So I shouldn't respond with my solution that implements goto for  
smalltalk and solves it using gotos entirely?

--
Travis Griggs
Objologist
"Some people are like slinkies, not really good for much, but they can  
bring a smile to your face when you push them down the stairs."

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] SmallTalk Collection

Mark Pirogovsky-3


Travis Griggs wrote:
> <.....>
>
>  
> So I shouldn't respond with my solution that implements goto for  
> smalltalk and solves it using gotos entirely?
>
>  
You should not  respond the solution  with "GO TO" prior to publishing
solution with complete implementation of "CASE" and  "CAST" alternatives...


> --
> Travis Griggs
> Objologist
> "Some people are like slinkies, not really good for much, but they can  
> bring a smile to your face when you push them down the stairs."
>
> _______________________________________________
>  
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] SmallTalk Collection

Reinout Heeck-2
In reply to this post by Roger Whitney
Roger Whitney wrote:
> I will talk  
> to my class today about inappropriateness of using this mailing list  
> to ask for solutions to homework problems.
>
>  
I hope that means that students who perused this list will get bonus
points.
Social skills and a network embedded in the Smalltalk community are
considered pros when we select new people.

Of course we should consider it a big minus if students fail to mention
that the subject at hand is a homework assignment...





Reinout
-------

>  
>> Hi guys,
>>
>> I am just beginner in Smaltalk and I have some problem with  
>> collection in
>> smalltalk.
>> For this problem I have to define the value of an alphabetic  
>> character based
>> on its location in the alphabet. So ?a? and  ?A? each have value 1, ?
>> b? and
>> ?B? each have 2, etc. Non-alphabetic characters can be considered to  
>> have
>> value 0.
>> The value of a word is the sum of the value of all its characters. So
>> ?Smalltalk? has value 101 and ?abc? has value 6.
>> A dollar word is a word whose value is 100.  I want to add a method  
>> to the
>> String class that returns all the dollar words in the string.
>>
>> So for example if the input is 'SmallTalk' the result is ('SmallTlk'
>> 'SmllTlk').
>>
>> Please kindly help me guys. Really appreciate your help.
>>
>> Thanks.
>>
>>    
>
>
>
> ----
> Roger Whitney              Department of Computer Science
> [hidden email]        San Diego State University
> http://www.eli.sdsu.edu/   San Diego, CA 92182-7720
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>  

--
*********************************************************************

Dit e-mailbericht is alleen bestemd voor de geadresseerde(n).

Gebruik door anderen is niet toegestaan. Indien u niet degeadresseerde(n) bent wordt u verzocht de verzender hiervan op de hoogte te stellen en het bericht te verwijderen. Door de elektronische verzending kunnen aan de inhoud van dit bericht geen rechten worden ontleend.

Soops B.V. is gevestigd te Amsterdam, Nederland, en is geregistreerd bij de Kamer van Koophandel onder nummer 33240368.
Soops B.V. levert volgens de Fenit voorwaarden, gedeponeerd te Den Haag op 8 december 1994 onder nummer 1994/189.
**********************************************************************

This e-mail message is intended to be exclusively for the addressee.

If you are not the intended recipient you are kindly requested not to make any use whatsoever of the contents and to notify the sender immediately by returning this e-mail message. No rights can be derived from this message.

Soops B.V. is a private limited liability company and has its seat at Amsterdam, The Netherlands and is registered with the Trade Registry of the Chamber of Commerce and Industry under number 33240368.
Soops B.V. delivers according to the General Terms and Conditions of Business of Fenit, registered at The Hague, The Netherlands on December 8th, 1994, under number 1994/189
**********************************************************************


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc