Finally managed to carve out some time to try this again. It looks like a few people have been looking into to this in the meantime (thanks a lot) and even though I can’t follow exactly what has been changed etc I can report that when I clone the latest opensmalltalk-vm I can get a working system. I can open a workspace and Try a few tests with no crashes:
(10**22) sin -0.8522008497671888 fib := [ :n | n > 2 ifTrue: [(fib value: n-2) + (fib value: n-1)] ifFalse: [1]]. "closure on block variable" fib value: 30. 832040 | x t | x := #(30 36 42 54 66 69). [1 to: 6 do: [:a | Transcript show: (Time millisecondsToRun: [t := (fib value: (x at: a))]). Transcript show: ' '. Transcript show: t. Transcript cr. ] ] forkAt: Processor userBackgroundPriority. 1081502 / 1000 / 60.0 18.025033333333333 1+2+3+4+5+6+7+8+9+10 55 Time durationToRun: [fib value: 42] 0:00:00:03.406797 2+2 4
I installed a clean FreeBSD 13 release. I used a minimal install for org and a simple wm: openbox Then did a git clone of: https://github.com/OpenSmalltalk/opensmalltalk-vm https://github.com/OpenSmalltalk/opensmalltalk-vm I changed the shell to bash then did: ./scripts/updateSCCSVersions Then I changed to opensmalltalk-vm/building/linux64x64/squeak.cog.spur/build Ran: ./mvm Down loaded the latest Squeak6.0-22104-64bit.image & .changes and renamed them in the dir to squeak.image & squeak.changes. I copied the SqueakV60.sources here too. ./squeak ran. I accepted all the defaults for configure & then installed system updates, FFI, and OS system.
And that’s it.
On 11. May 2023, at 09:52, David Gray dgray@iesl.forth.gr wrote:
Finally managed to carve out some time to try this again. It looks like a few people have been looking into to this in the meantime (thanks a lot) and even though I can’t follow exactly what has been changed etc I can report that when I clone the latest opensmalltalk-vm I can get a working system.
hoooray!
-t
I can open a workspace and Try a few tests with no crashes:
(10**22) sin -0.8522008497671888 fib := [ :n | n > 2 ifTrue: [(fib value: n-2) + (fib value: n-1)] ifFalse: [1]]. "closure on block variable" fib value: 30. 832040 | x t | x := #(30 36 42 54 66 69). [1 to: 6 do: [:a | Transcript show: (Time millisecondsToRun: [t := (fib value: (x at: a))]). Transcript show: ' '. Transcript show: t. Transcript cr. ] ] forkAt: Processor userBackgroundPriority. 1081502 / 1000 / 60.0 18.025033333333333 1+2+3+4+5+6+7+8+9+10 55 Time durationToRun: [fib value: 42] 0:00:00:03.406797 2+2 4
I installed a clean FreeBSD 13 release. I used a minimal install for org and a simple wm: openbox Then did a git clone of: https://github.com/OpenSmalltalk/opensmalltalk-vm I changed the shell to bash then did: ./scripts/updateSCCSVersions Then I changed to opensmalltalk-vm/building/linux64x64/squeak.cog.spur/build Ran: ./mvm Down loaded the latest Squeak6.0-22104-64bit.image & .changes and renamed them in the dir to squeak.image & squeak.changes. I copied the SqueakV60.sources here too. ./squeak ran. I accepted all the defaults for configure & then installed system updates, FFI, and OS system.
And that’s it.
Excellent!
All the best,
Ron Teitelbaum Ron
On Thu, May 11, 2023 at 3:54 AM Tobias Pape Das.Linux@gmx.de wrote:
On 11. May 2023, at 09:52, David Gray dgray@iesl.forth.gr wrote:
Finally managed to carve out some time to try this again. It looks like a few people have been looking into to this in the
meantime (thanks a lot) and even though I can’t follow exactly what has been changed etc I can report that when I clone the latest opensmalltalk-vm I can get a working system.
hoooray!
-t
I can open a workspace and Try a few tests with no crashes:
(10**22) sin -0.8522008497671888 fib := [ :n | n > 2 ifTrue: [(fib value: n-2) + (fib value: n-1)]
ifFalse: [1]]. "closure on block variable"
fib value: 30. 832040 | x t | x := #(30 36 42 54 66 69). [1 to: 6 do: [:a | Transcript show: (Time millisecondsToRun: [t := (fib
value: (x at: a))]). Transcript show: ' '. Transcript show: t. Transcript cr. ] ] forkAt: Processor userBackgroundPriority.
1081502 / 1000 / 60.0 18.025033333333333 1+2+3+4+5+6+7+8+9+10 55 Time durationToRun: [fib value: 42] 0:00:00:03.406797 2+2 4
I installed a clean FreeBSD 13 release. I used a minimal install for org and a simple wm: openbox Then did a git clone of:
https://github.com/OpenSmalltalk/opensmalltalk-vm
I changed the shell to bash then did: ./scripts/updateSCCSVersions Then I changed to
opensmalltalk-vm/building/linux64x64/squeak.cog.spur/build
Ran: ./mvm Down loaded the latest Squeak6.0-22104-64bit.image & .changes and
renamed them in the dir to squeak.image & squeak.changes. I copied the SqueakV60.sources here too.
./squeak ran. I accepted all the defaults for configure & then installed system
updates, FFI, and OS system.
And that’s it.
Hi Folks.
Is there a standard Stream idiom to get all the data up to a space (or other separator?)
Here is my motive....
For this simple RosettaCode task https://rosettacode.org/wiki/A%2BB#Smalltalk
I need to put two numbers on a stream and display their sum on stout
The below works fine for single digit integers.
|task input |
task := [:inStream :outStream |
|processLine|
processLine :=
[
|a b space outstring|
a := (inStream next asString).
space := inStream next.
b := (inStream next asString).
"is validation part of the task?"
self assert:( a asInteger between:-1000 and: 1000).
self assert:( b asInteger between:-1000 and: 1000).
outstring := a , ' ' , b , ' ' , ((a asInteger) + (b asInteger)).
outStream store: outstring ; ensureCr; flush.
].
[ inStream atEnd ] whileFalse:processLine.
].
input := Project uiManager request: 'Enter Two Numbers Separated By a Space'.
input isEmptyOrNil ifTrue: [^ self].
task value: input readStream value: (FileStream stdout).
However, I would like to generalize this to handle multi-digit Integers and Real Numbers (i.e. decimal places, not fractions, not e, not i, not square roots, not pi, ...just 123.456 sort of stuff)
I will be adding any answers/solutions to Doc-SqueakHOWTOHelp so I have ready access to this answer when I need it again.
Thanks in advance.
Hi Timothy --
Try #upToAnyOf: and CharacterSet such as "Character separators":
'Hello Squeak' readStream upToAnyOf: Character separators.
Best, Marcel Am 31.08.2023 09:23:32 schrieb gettimothy gettimothy@zoho.com: Hi Folks.
Is there a standard Stream idiom to get all the data up to a space (or other separator?)
Here is my motive....
For this simple RosettaCode task https://rosettacode.org/wiki/A%2BB#Smalltalk [https://rosettacode.org/wiki/A%2BB#Smalltalk]
I need to put two numbers on a stream and display their sum on stout
The below works fine for single digit integers.
|task input |
task := [:inStream :outStream |
|processLine|
processLine :=
[
|a b space outstring|
a := (inStream next asString).
space := inStream next.
b := (inStream next asString).
"is validation part of the task?"
self assert:( a asInteger between:-1000 and: 1000).
self assert:( b asInteger between:-1000 and: 1000).
outstring := a , ' ' , b , ' ' , ((a asInteger) + (b asInteger)).
outStream store: outstring ; ensureCr; flush.
].
[ inStream atEnd ] whileFalse:processLine.
].
input := Project uiManager request: 'Enter Two Numbers Separated By a Space'.
input isEmptyOrNil ifTrue: [^ self].
task value: input readStream value: (FileStream stdout).
However, I would like to generalize this to handle multi-digit Integers and Real Numbers (i.e. decimal places, not fractions, not e, not i, not square roots, not pi, ...just 123.456 sort of stuff)
I will be adding any answers/solutions to Doc-SqueakHOWTOHelp so I have ready access to this answer when I need it again.
Thanks in advance.
Hi Timothy,
if you want to use Streams, you could also send #nextFloat:
s := '2.14 -15' readStream. s nextFloat. "2.14" s nextFloat. "-15.0 "
(Shameless self-promotion: The SimulationMethodFinder [1] can help you to find such selectors - this is how I discovered this message just now.)
Other comments on your code: You only need to convert each value once into an integer if you store the result in a and b. Actually, you could even forego any conversion if you do not need validation since String>>#+ automatically handles that for you. You are using a lot of redundant brackets, only two pairs of them in your code are required. :-) Instead of string concatenation, you could also use String>>#format: again:
outstring := '{1} {2} {3}' format: {a. b. a + b}.
Happy Squeaking! Christoph
[1] https://github.com/LinqLover/SimulationStudio#simulationstudio-tools
--- Sent from Squeak Inbox Talk
On 2023-08-31T09:27:42+02:00, marcel.taeumel@hpi.de wrote:
Hi Timothy --
Try #upToAnyOf: and CharacterSet such as "Character separators":
'Hello Squeak' readStream upToAnyOf: Character separators.
Best, Marcel Am 31.08.2023 09:23:32 schrieb gettimothy <gettimothy(a)zoho.com>: Hi Folks.
Is there a standard Stream idiom to get all the data up to a space (or other separator?)
Here is my motive....
For this simple RosettaCode task https://rosettacode.org/wiki/A%2BB#Smalltalk [https://rosettacode.org/wiki/A%2BB#Smalltalk]
I need to put two numbers on a stream and display their sum on stout
The below works fine for single digit integers.
|task input |
task := [:inStream :outStream |
|processLine|
processLine :=
[
|a b space outstring|
a := (inStream next asString).
space := inStream next.
b := (inStream next asString).
"is validation part of the task?"
self assert:( a asInteger between:-1000 and: 1000).
self assert:( b asInteger between:-1000 and: 1000).
outstring := a , ' ' , b , ' ' , ((a asInteger) + (b asInteger)).
outStream store: outstring ; ensureCr; flush.
].
[ inStream atEnd ] whileFalse:processLine.
].
input := Project uiManager request: 'Enter Two Numbers Separated By a Space'.
input isEmptyOrNil ifTrue: [^ self].
task value: input readStream value: (FileStream stdout).
However, I would like to generalize this to handle multi-digit Integers and Real Numbers (i.e. decimal places, not fractions, not e, not i, not square roots, not pi, ...just 123.456 sort of stuff)
I will be adding any answers/solutions to Doc-SqueakHOWTOHelp so I have ready access to this answer when I need it again.
Thanks in advance.
["MethodFinder.png"]
Thank you for your time and answers. much appreciated.
cordially,
---- On Thu, 31 Aug 2023 05:00:00 -0400 christoph.thiede@student.hpi.uni-potsdam.de wrote ---
Hi Timothy,
if you want to use Streams, you could also send #nextFloat:
s := '2.14 -15' readStream. s nextFloat. "2.14" s nextFloat. "-15.0 "
(Shameless self-promotion: The SimulationMethodFinder [1] can help you to find such selectors - this is how I discovered this message just now.)
Other comments on your code: You only need to convert each value once into an integer if you store the result in a and b. Actually, you could even forego any conversion if you do not need validation since String>>#+ automatically handles that for you. You are using a lot of redundant brackets, only two pairs of them in your code are required. :-) Instead of string concatenation, you could also use String>>#format: again:
outstring := '{1} {2} {3}' format: {a. b. a + b}.
Happy Squeaking! Christoph
[1] https://github.com/LinqLover/SimulationStudio#simulationstudio-tools
--- Sent from Squeak Inbox Talk
On 2023-08-31T09:27:42+02:00, mailto:marcel.taeumel@hpi.de wrote:
Hi Timothy --
Try #upToAnyOf: and CharacterSet such as "Character separators":
'Hello Squeak' readStream upToAnyOf: Character separators.
Best, Marcel Am 31.08.2023 09:23:32 schrieb gettimothy <gettimothy(a)zoho.com>: Hi Folks.
Is there a standard Stream idiom to get all the data up to a space (or other separator?)
Here is my motive....
For this simple RosettaCode task https://rosettacode.org/wiki/A%2BB#Smalltalk [https://rosettacode.org/wiki/A%2BB#Smalltalk]
I need to put two numbers on a stream and display their sum on stout
The below works fine for single digit integers.
|task input |
task := [:inStream :outStream |
|processLine|
processLine :=
[
|a b space outstring|
a := (inStream next asString).
space := inStream next.
b := (inStream next asString).
"is validation part of the task?"
self assert:( a asInteger between:-1000 and: 1000).
self assert:( b asInteger between:-1000 and: 1000).
outstring := a , ' ' , b , ' ' , ((a asInteger) + (b asInteger)).
outStream store: outstring ; ensureCr; flush.
].
[ inStream atEnd ] whileFalse:processLine.
].
input := Project uiManager request: 'Enter Two Numbers Separated By a Space'.
input isEmptyOrNil ifTrue: [^ self].
task value: input readStream value: (FileStream stdout).
However, I would like to generalize this to handle multi-digit Integers and Real Numbers (i.e. decimal places, not fractions, not e, not i, not square roots, not pi, ...just 123.456 sort of stuff)
I will be adding any answers/solutions to Doc-SqueakHOWTOHelp so I have ready access to this answer when I need it again.
Thanks in advance.
["MethodFinder.png"]_______________________________________________ Beginners mailing list -- mailto:beginners@lists.squeakfoundation.org To unsubscribe send an email to mailto:beginners-leave@lists.squeakfoundation.org
beginners@lists.squeakfoundation.org