Hello, friends.
This problem which confuses me comes from a question
<http://forum.world.st/quot-Print-specific-integers-quot-Error-message-how-t…>
I asked in "Squeak - Beginners" days ago.
These are some special integers: myArray := #(2 32 44 67 89 111 123)
These special integers need to be specially labelled from integer 1 to 130.
The rest normal numbers which myArray doesn't include will be printed also.
Here's the code:
*|a n myArray|
myArray := #(2 32 44 67 89 111 123).
n := 1.
a := myArray at: n.
1 to: 130 do: [:i|
i = a
ifTrue: [
Transcript show: ('Special number: i = {1}, a = {2}' format:
{i. a}).
Transcript cr.
n := n + 1.
n = 8
ifTrue: [a := 'I am no longer a number'.]
ifFalse: [a := myArray at: n. ].
]
ifFalse: [
Transcript show: ('i = {1}, a = {2}' format: {i. a}).
Transcript cr.
].
].
Transcript show: a; cr. 'Last line'
*
Now comes something that makes my head big.
If I choose everything and do them, the last line, which should tell me what
a is when program jumps out of the loop, exactly shows that a is "I am no
longer a number".
However, if I choose everything except the last line, and do them. After
that, I do the last line. The output is nil.
Why is a nil ? Why's that?
In order to make my question explicit, I recorded a video:
https://www.youtube.com/watch?v=pUQAEO4uSpk
-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
In C loop, there is break method which allows the program to jump out of the
loop when certain criteria has been met.
What is the counterpart in Smalltalk if there's one?
-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
Hello, *what I want is:*
>From integers 1 to 130, I want to print some specific integers already given
in an array.
They are: 2 32 44 67 89 111 123 which are stored in small-to-big order.
*Here's my codes:*
|a n myArray|
myArray := #(2 32 44 67 89 111 123).
n := 1.
a := myArray at: n.
1 to: 130 do: [:i|
i = a
ifTrue: [
Transcript show: i; cr.
n := n + 1.
a := myArray at: n.
].
].
The output is very good except for an Error Message.
<http://forum.world.st/file/t371379/errormessage.png>
By my current level, I have no idea why that Error Message appears.
Q1: Why Error Message appears ?
Q2: How can I improve that?
-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
I understand in Smalltalk numerical calculation, if without round brackets,
everything starts being calculated from left to right. Nothing follows the
rule of multiplication and division having more precedence over addition and
subtraction.
Like the following codes
3 + 3 * 2
The print output is 12 while in mathematics we get 9
But when I started to try power calculation, like
91 raisedTo: 3 + 1.
I thought the answer should be 753572
What I actual get is 68574964
Why's that?
Is it because that +, -, *, / have more precedence over power ?
-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
I was wondering if Squeak has some automatic indentation function to make
codes in disorder become clean and well-indented in a flash, just like what
we can do in VIM and MS VISUAL STUDIO.
-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
Hello,
I am new to Squeak, and I'm using squeack 5.1 all-in-one.
How can I add auto-complete sentences/methods suggestion feature?
It is really needed.. :/
Thank you !
David
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
In Squeak programming , "comment " is very needed in order to make the
source code easier for humans to understand and maintain.
However, I find "//" and /* */ to be not working.
What can I do in order to comment in Squeak programming ?
-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
I am using Smalltalk to type in Transcript window a 1-9 multiplication table
.
Here is my code:
*1 to: 9 do: [:i|
1 to: i do: [:j|
Transcript show: j.
Transcript show: ' * '.
Transcript show: i.
Transcript show: ' = '.
Transcript show: j * i.
Transcript show: ' '.
].
Transcript show: ' '; cr.
].*
As can be seen, the above code, although working fine, looks far from
beautiful and concise.
I had hoped to write something like :
*Transcript show: j '*' i '=' j * i.*
Unfortunately, they are wrong. I remember C has a very nice way to handle
that issue of mine.
Like, *printf("%d * %d = %d ", j, i, j * i);*
Is there a more elegant way to make Smalltalk codes elegant in this
situation ?
-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
I've heard that Smalltalk is also an OS. How can I install Smalltalk on my
X86 instead of Linux or windows?
That must be of great fun to install Smalltalk on a bare-metal machine,
isn't it?
What are the steps to do that? Any tutorials?
-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout,
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html