smalltalk

How do I display the new Squeak background in my trunk image?

不想你离开。 提交于 2019-12-24 15:16:27
问题 I have a Squeak 4.3 image that I have updated through 4.4 by using the trunk update stream, which pulls down source code updates from the Monticello repository here How do I get the new 4.4 desktop? In particular, how do I replace the brown antique paper background with the new grey Ulam Spiral background? 回答1: You can download the wallpaper itself here. (This URL points to the wallpaper of the current Squeak release, but you ought to have at least 6 months from today before it changes :) )

Generating all combinations from collections in Smalltalk

好久不见. 提交于 2019-12-24 02:33:24
问题 I've seen this problem resolved for C# and other languages but not for Smalltalk. I have 3 collections, for example: a := #(3 4 5). b := #(4 1 2). c := #(5 2 3). and I need to make all possible combinations, i. e.: #(3 4 5) #(3 4 2) #(3 4 3) #(3 1 5) #(3 1 2) #(3 1 3) #(3 2 5) #(3 2 2) #(3 2 3) #(4 4 5) ... I have seen in Squeak and Pharo there is combinations:atATimeDo: but I don't get how to use it for this case. This is not homework. Any help? 回答1: here is the code from Smalltalk/X's class

GNU Smalltalk: Problem with Example in Tutorial (Object creation)

≡放荡痞女 提交于 2019-12-24 01:53:24
问题 I tried to run the example of GNU Smalltalk in the documentation but ran into an issue. Object subclass: Account [ | balance | new [ | r | r := super new. r init. ^r ] init [ 'initialize account' printNl. balance := 0 ] get [ ^balance ] ] In the new method the init message is never sent to the Account method. Heres my output: st> Account new get nil st> Account new init get 'initialize account' 0 I took this example from the GNU Smalltalk Documentation. Can somebody help me spot the error? I

Why this class/instance variable is not being intialized?

扶醉桌前 提交于 2019-12-24 01:39:06
问题 I am trying to use gnu-smalltalk. In following code of a simple class with a variable, I find it is not getting initialized to the given value: Object subclass: Myclass[ |mainval| mainval := 555. getmainval [^mainval] ] gc := Myclass new. gc getmainval printNl. The object gets created without any error. But, the output is: nil while I had expected it to be 555. If I add a method to assign a value to it and call it after creating an instance of the class, it works. Where is the problem and how

Squeak Smalltalk, why sometimes the reduced method doesn't work?

蹲街弑〆低调 提交于 2019-12-23 22:01:12
问题 (2332 / 2332) reduced (2332 / 2) reduced (2332 / 322) reduced (1166/161) (2332 / 3) reduced (2332/3) (2332 / 2432423) reduced (2332/2432423) Look at the above codes. The first and second, when printed, do not work. The MessageNotUnderstood window pops up. And the 3rd, 4th, 5th code are okay. Results come out right. Why does the reduced method not work? Is it because the reduced method fails to handle final results which are integers like Uko guesses ? 回答1: Fractions are reduced automatically

Pharo Smalltalk: Reading from TextMorph

拟墨画扇 提交于 2019-12-23 19:08:19
问题 In Smalltalk using Pharo, I'm creating an application that reads the user input and does X. So far I've managed to make a TextMorph that a user could enter a value into, but I'm unsure of how to read from TextMorphs and then do something with the value. Any ideas? Thanks 回答1: Well, you can simply send text to your morph and get it's contents. So you could have a button and when button is pressed you do something with contents: input := TextMorph new. button := SimpleButtonMorph new target:

Simple class definition error in smalltalk

╄→гoц情女王★ 提交于 2019-12-23 17:10:42
问题 I am trying to use smalltalk with smalltalk/x-jv branch. I have following simple code: Object subclass: Myclass[ |mainval| init [mainval := 555] getmainval [^mainval] ] gc := Myclass new. gc init. gc getmainval printNl. I am trying to run it on command line with stc command of smalltalk/x-jv, but it it not working. Following is the error: $ ./stc testsrc.st testsrc.st, line 1: Error: syntax error in 'class definition' near "Myclass" (char/token=286 / 0x11e) (fileIn expression) Where is the

How can I remove diacritics (umlauts) from a String?

谁说我不能喝 提交于 2019-12-23 15:11:14
问题 How can I convert a string, such as Příliš žluťoučký kůň úpěl ďábelské ódy. into Prilis zlutoucky kun upel dabelske ody. ? The source string is in Unicode, so in principle it should be possible to use normalization/decomposition to separate the umlaut. Unfortunately I didn't see any library in Pharo (maybe Zinc hidden somewhere?) that would support either stripping umlauts or decomposition. 回答1: You can try Diacriticals package Installation Metacello new smalltalkhubUser: 'Pharo' project:

For loop for array in Pharo Smalltalk

时光怂恿深爱的人放手 提交于 2019-12-23 12:29:51
问题 I'm trying to make an array with random numbers (just 0 or 1), but when I run it, it just prints this: End of statement list encountered -> This is my code: GenList | lista | lista := Array new: 31. 1 to: 30 do: [ :i | lista at: i put: 2 atRandom - 1] ^lista What can I do? 回答1: Some interesting things to consider: 1. The method selector doesn't start with a lowercase letter It is a tradition for selectors to start with a lowercase letter. In this sense, genLista would be more correct than

Would it be possible to make declaration of temp vars optional in Smalltalk?

荒凉一梦 提交于 2019-12-23 12:07:34
问题 When writing Smalltalk code that uses temporaries you write something like: SequenceableCollection>>#swap: index1 with: index2 | temp | temp := self at: index1. self at: index1 put: (self at: index2). self at: index2 put: temp. I find the syntax for declaring temporaries a bit old fashioned and cumbersome. Actually, is one of the places where you usually stop thinking in your domain and focus in computer (you wrote your method, you are ready to accept the code, but have to "cleanup" your