Hi Folks,
Thanks to Marcel's help on String format:
I have a proposed version for the Rosetta Code entry for 99 bottles of beer
https://rosettacode.org/wiki/99_bottles_of_beer
|template|
Transcript clear.
template:='{1} bottles of beer on the wall
{2} bottles of beer
Take one down, pass it around
{3} bottles of beer on the wall'.
99 to: 1 by: -1 do:[:v |
Transcript show: (template format: {(v asString) . (v asString) . ((v -1) asString)}); cr; cr.
].
Transcript show: 'hic!'; cr.
Any improvements suggestions much appreciated.
If anybody has a Rosetta code account and wants to update that example, please do so.
cordially.
Here is a a version that handles the plural/single case
|bottles|
Transcript clear.
bottles:='{1} bottle{2} of beer on the wall
{3} bottle{4} of beer
Take one down, pass it around
{5} bottle{6} of beer on the wall'.
99 to: 1 by: -1 do:[:v |
(v > 1)
ifTrue:[Transcript show: (bottles format: {(v asString) . 's' . (v asString) . 's' . ((v -1) asString). 's'}); cr; cr.]
ifFalse:[Transcript show: (bottles format: {(v asString) . '' . (v asString) . '' . ((v -1) asString). ''}); cr; cr.]
].
Transcript show: 'hic!'; cr.
---- On Mon, 21 Aug 2023 09:56:11 -0400 gettimothy gettimothy@zoho.com wrote ---
Hi Folks,
Thanks to Marcel's help on String format:
I have a proposed version for the Rosetta Code entry for 99 bottles of beer
https://rosettacode.org/wiki/99_bottles_of_beer
|template|
Transcript clear.
template:='{1} bottles of beer on the wall
{2} bottles of beer
Take one down, pass it around
{3} bottles of beer on the wall'.
99 to: 1 by: -1 do:[:v |
Transcript show: (template format: {(v asString) . (v asString) . ((v -1) asString)}); cr; cr.
].
Transcript show: 'hic!'; cr.
Any improvements suggestions much appreciated.
If anybody has a Rosetta code account and wants to update that example, please do so.
cordially.
Why not:
bottles:='{1} bottle{2} of beer on the wall {1} bottle{2} of beer Take one down, pass it around {3} bottle{4} of beer on the wall'.
Also, for v=2, v-1 bottle does not require a plural... So maybe, use this:
plurals := #('' 's'). Transcript show: (bottles format: {(v asString) . (plurals atPin:v) . ((v -1) asString). plurals at: v-1}); cr; cr.
Le lun. 21 août 2023 à 16:47, gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org a écrit :
Here is a a version that handles the plural/single case
|bottles| Transcript clear. bottles:='{1} bottle{2} of beer on the wall {3} bottle{4} of beer Take one down, pass it around {5} bottle{6} of beer on the wall'. 99 to: 1 by: -1 do:[:v | (v > 1) ifTrue:[Transcript show: (bottles format: {(v asString) . 's' . (v asString) . 's' . ((v -1) asString). 's'}); cr; cr.] ifFalse:[Transcript show: (bottles format: {(v asString) . '' . (v asString) . '' . ((v -1) asString). ''}); cr; cr.] ]. Transcript show: 'hic!'; cr.
---- On Mon, 21 Aug 2023 09:56:11 -0400 gettimothy gettimothy@zoho.com wrote ---
Hi Folks,
Thanks to Marcel's help on String format: I have a proposed version for the Rosetta Code entry for 99 bottles of beer
https://rosettacode.org/wiki/99_bottles_of_beer
|template| Transcript clear. template:='{1} bottles of beer on the wall {2} bottles of beer Take one down, pass it around {3} bottles of beer on the wall'.
99 to: 1 by: -1 do:[:v | Transcript show: (template format: {(v asString) . (v asString) . ((v -1) asString)}); cr; cr. ]. Transcript show: 'hic!'; cr.
Any improvements suggestions much appreciated.
If anybody has a Rosetta code account and wants to update that example, please do so.
cordially.
Argh, I posted too fast, also use `plurals atPin: v-1`and remove excess () pairs.
Transcript show: (bottles format: {v asString. plurals atPin:v. (v -1) asString. plurals atPin: v-1}); cr; cr.
By the way, I had a hard time finding the atPin: selector...
Le lun. 21 août 2023 à 18:43, Nicolas Cellier nicolas.cellier.aka.nice@gmail.com a écrit :
Why not:
bottles:='{1} bottle{2} of beer on the wall {1} bottle{2} of beer Take one down, pass it around {3} bottle{4} of beer on the wall'.
Also, for v=2, v-1 bottle does not require a plural... So maybe, use this:
plurals := #('' 's'). Transcript show: (bottles format: {(v asString) . (plurals
atPin:v) . ((v -1) asString). plurals at: v-1}); cr; cr.
Le lun. 21 août 2023 à 16:47, gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org a écrit :
Here is a a version that handles the plural/single case
|bottles| Transcript clear. bottles:='{1} bottle{2} of beer on the wall {3} bottle{4} of beer Take one down, pass it around {5} bottle{6} of beer on the wall'. 99 to: 1 by: -1 do:[:v | (v > 1) ifTrue:[Transcript show: (bottles format: {(v asString) . 's' . (v asString) . 's' . ((v -1) asString). 's'}); cr; cr.] ifFalse:[Transcript show: (bottles format: {(v asString) . '' . (v asString) . '' . ((v -1) asString). ''}); cr; cr.] ]. Transcript show: 'hic!'; cr.
---- On Mon, 21 Aug 2023 09:56:11 -0400 gettimothy gettimothy@zoho.com wrote ---
Hi Folks,
Thanks to Marcel's help on String format: I have a proposed version for the Rosetta Code entry for 99 bottles of beer
https://rosettacode.org/wiki/99_bottles_of_beer
|template| Transcript clear. template:='{1} bottles of beer on the wall {2} bottles of beer Take one down, pass it around {3} bottles of beer on the wall'.
99 to: 1 by: -1 do:[:v | Transcript show: (template format: {(v asString) . (v asString) . ((v -1) asString)}); cr; cr. ]. Transcript show: 'hic!'; cr.
Any improvements suggestions much appreciated.
If anybody has a Rosetta code account and wants to update that example, please do so.
cordially.
On 21. Aug 2023, at 18:46, Nicolas Cellier nicolas.cellier.aka.nice@gmail.com wrote:
Argh, I posted too fast, also use `plurals atPin: v-1`and remove excess () pairs.
Transcript show: (bottles format: {v asString. plurals atPin:v. (v -1) asString. plurals atPin: v-1}); cr; cr.
By the way, I had a hard time finding the atPin: selector...
I found it by accident browsing around the collection protocol like 5 years ago. Thats one of the reasons I sometimes aimlessly browse around the image :D -t
Le lun. 21 août 2023 à 18:43, Nicolas Cellier nicolas.cellier.aka.nice@gmail.com a écrit :
Why not:
bottles:='{1} bottle{2} of beer on the wall {1} bottle{2} of beer Take one down, pass it around {3} bottle{4} of beer on the wall'.
Also, for v=2, v-1 bottle does not require a plural... So maybe, use this:
plurals := #('' 's'). Transcript show: (bottles format: {(v asString) . (plurals atPin:v) . ((v -1) asString). plurals at: v-1}); cr; cr.
Le lun. 21 août 2023 à 16:47, gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org a écrit :
Here is a a version that handles the plural/single case
|bottles| Transcript clear. bottles:='{1} bottle{2} of beer on the wall {3} bottle{4} of beer Take one down, pass it around {5} bottle{6} of beer on the wall'. 99 to: 1 by: -1 do:[:v | (v > 1) ifTrue:[Transcript show: (bottles format: {(v asString) . 's' . (v asString) . 's' . ((v -1) asString). 's'}); cr; cr.] ifFalse:[Transcript show: (bottles format: {(v asString) . '' . (v asString) . '' . ((v -1) asString). ''}); cr; cr.] ]. Transcript show: 'hic!'; cr.
---- On Mon, 21 Aug 2023 09:56:11 -0400 gettimothy gettimothy@zoho.com wrote ---
Hi Folks,
Thanks to Marcel's help on String format: I have a proposed version for the Rosetta Code entry for 99 bottles of beer
https://rosettacode.org/wiki/99_bottles_of_beer
|template| Transcript clear. template:='{1} bottles of beer on the wall {2} bottles of beer Take one down, pass it around {3} bottles of beer on the wall'.
99 to: 1 by: -1 do:[:v | Transcript show: (template format: {(v asString) . (v asString) . ((v -1) asString)}); cr; cr. ]. Transcript show: 'hic!'; cr.
Any improvements suggestions much appreciated.
If anybody has a Rosetta code account and wants to update that example, please do so.
cordially.
Thank you all for your help and improvements.
The modified code is up at:
https://rosettacode.org/wiki/99_bottles_of_beer#Smalltalk
Also, pro-tip.
When investigating which atPin: method is called, DO NOT put a breakpoint in the RunnArray version .
cordially
---- On Mon, 21 Aug 2023 12:55:56 -0400 Tobias Pape Das.Linux@gmx.de wrote ---
On 21. Aug 2023, at 18:46, Nicolas Cellier mailto:nicolas.cellier.aka.nice@gmail.com wrote:
Argh, I posted too fast, also use `plurals atPin: v-1`and remove excess () pairs.
Transcript show: (bottles format: {v asString. plurals atPin:v. (v -1) asString. plurals atPin: v-1}); cr; cr.
By the way, I had a hard time finding the atPin: selector...
I found it by accident browsing around the collection protocol like 5 years ago. Thats one of the reasons I sometimes aimlessly browse around the image :D -t
Le lun. 21 août 2023 à 18:43, Nicolas Cellier mailto:nicolas.cellier.aka.nice@gmail.com a écrit :
Why not:
bottles:='{1} bottle{2} of beer on the wall {1} bottle{2} of beer Take one down, pass it around {3} bottle{4} of beer on the wall'.
Also, for v=2, v-1 bottle does not require a plural... So maybe, use this:
plurals := #('' 's'). Transcript show: (bottles format: {(v asString) . (plurals atPin:v) . ((v -1) asString). plurals at: v-1}); cr; cr.
Le lun. 21 août 2023 à 16:47, gettimothy via Squeak-dev mailto:squeak-dev@lists.squeakfoundation.org a écrit :
Here is a a version that handles the plural/single case
|bottles| Transcript clear. bottles:='{1} bottle{2} of beer on the wall {3} bottle{4} of beer Take one down, pass it around {5} bottle{6} of beer on the wall'. 99 to: 1 by: -1 do:[:v | (v > 1) ifTrue:[Transcript show: (bottles format: {(v asString) . 's' . (v asString) . 's' . ((v -1) asString). 's'}); cr; cr.] ifFalse:[Transcript show: (bottles format: {(v asString) . '' . (v asString) . '' . ((v -1) asString). ''}); cr; cr.] ]. Transcript show: 'hic!'; cr.
---- On Mon, 21 Aug 2023 09:56:11 -0400 gettimothy mailto:gettimothy@zoho.com wrote ---
Hi Folks,
Thanks to Marcel's help on String format: I have a proposed version for the Rosetta Code entry for 99 bottles of beer
https://rosettacode.org/wiki/99_bottles_of_beer
|template| Transcript clear. template:='{1} bottles of beer on the wall {2} bottles of beer Take one down, pass it around {3} bottles of beer on the wall'.
99 to: 1 by: -1 do:[:v | Transcript show: (template format: {(v asString) . (v asString) . ((v -1) asString)}); cr; cr. ]. Transcript show: 'hic!'; cr.
Any improvements suggestions much appreciated.
If anybody has a Rosetta code account and wants to update that example, please do so.
cordially.
It's interesting (and rather sad) to look at the other languages on that page; so many deeply ugly syntax choices.
On 2023-08-22, at 7:24 AM, gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org wrote:
Thank you all for your help and improvements.
The modified code is up at:
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Futuristic: It will only run on a next generation supercomputer.
Here's my proposal for improvement:
| bottles | Transcript clear. bottles := '{1} {2} of beer on the wall {1} {2} of beer Take one down, pass it around {3} {4} of beer on the wall'. 99 to: 1 by: -1 do: [:i | Transcript show: (bottles format: { i. 'bottle' asPluralBasedOn: i. i - 1. 'bottle' asPluralBasedOn: i - 1}); cr; cr]. Transcript show: 'hic!'; cr.
Best, Christoph
--- Sent from Squeak Inbox Talk
On 2023-08-22T09:29:01-07:00, tim@rowledge.org wrote:
It's interesting (and rather sad) to look at the other languages on that page; so many deeply ugly syntax choices.
On 2023-08-22, at 7:24 AM, gettimothy via Squeak-dev <squeak-dev(a)lists.squeakfoundation.org> wrote:
Thank you all for your help and improvements.
The modified code is up at:
tim
tim Rowledge; tim(a)rowledge.org; http://www.rowledge.org/tim Futuristic: It will only run on a next generation supercomputer.
Interesting!
Its up and posted.
I have also incorporated into Doc-RossetaCode Help
cordially,
---- On Tue, 22 Aug 2023 17:12:30 -0400 christoph.thiede@student.hpi.uni-potsdam.de wrote ---
Here's my proposal for improvement:
| bottles | Transcript clear. bottles := '{1} {2} of beer on the wall {1} {2} of beer Take one down, pass it around {3} {4} of beer on the wall'. 99 to: 1 by: -1 do: [:i | Transcript show: (bottles format: { i. 'bottle' asPluralBasedOn: i. i - 1. 'bottle' asPluralBasedOn: i - 1}); cr; cr]. Transcript show: 'hic!'; cr.
Best, Christoph
--- Sent from https://github.com/hpi-swa-lab/squeak-inbox-talk
On 2023-08-22T09:29:01-07:00, mailto:tim@rowledge.org wrote:
It's interesting (and rather sad) to look at the other languages on that page; so many deeply ugly syntax choices.
On 2023-08-22, at 7:24 AM, gettimothy via Squeak-dev <squeak-dev(a)lists.squeakfoundation.org> wrote:
Thank you all for your help and improvements.
The modified code is up at:
tim
tim Rowledge; tim(a)rowledge.org; http://www.rowledge.org/tim Futuristic: It will only run on a next generation supercomputer.
Hey, that's nice.
I will modify it .
and post it at Rosetta code, or feel free to modify my example there online.
cordially,
---- On Mon, 21 Aug 2023 12:46:09 -0400 Nicolas Cellier nicolas.cellier.aka.nice@gmail.com wrote ---
Argh, I posted too fast, also use `plurals atPin: v-1`and remove excess () pairs.
Transcript show: (bottles format: {v asString. plurals atPin:v. (v -1) asString. plurals atPin: v-1}); cr; cr.
By the way, I had a hard time finding the atPin: selector...
Le lun. 21 août 2023 à 18:43, Nicolas Cellier mailto:nicolas.cellier.aka.nice@gmail.com a écrit :
Why not:
bottles:='{1} bottle{2} of beer on the wall {1} bottle{2} of beer Take one down, pass it around {3} bottle{4} of beer on the wall'.
Also, for v=2, v-1 bottle does not require a plural... So maybe, use this:
plurals := #('' 's'). Transcript show: (bottles format: {(v asString) . (plurals
atPin:v) . ((v -1) asString). plurals at: v-1}); cr; cr.
Le lun. 21 août 2023 à 16:47, gettimothy via Squeak-dev mailto:squeak-dev@lists.squeakfoundation.org a écrit :
Here is a a version that handles the plural/single case
|bottles| Transcript clear. bottles:='{1} bottle{2} of beer on the wall {3} bottle{4} of beer Take one down, pass it around {5} bottle{6} of beer on the wall'. 99 to: 1 by: -1 do:[:v | (v > 1) ifTrue:[Transcript show: (bottles format: {(v asString) . 's' . (v asString) . 's' . ((v -1) asString). 's'}); cr; cr.] ifFalse:[Transcript show: (bottles format: {(v asString) . '' . (v asString) . '' . ((v -1) asString). ''}); cr; cr.] ]. Transcript show: 'hic!'; cr.
---- On Mon, 21 Aug 2023 09:56:11 -0400 gettimothy mailto:gettimothy@zoho.com wrote ---
Hi Folks,
Thanks to Marcel's help on String format: I have a proposed version for the Rosetta Code entry for 99 bottles of beer
https://rosettacode.org/wiki/99_bottles_of_beer
|template| Transcript clear. template:='{1} bottles of beer on the wall {2} bottles of beer Take one down, pass it around {3} bottles of beer on the wall'.
99 to: 1 by: -1 do:[:v | Transcript show: (template format: {(v asString) . (v asString) . ((v -1) asString)}); cr; cr. ]. Transcript show: 'hic!'; cr.
Any improvements suggestions much appreciated.
If anybody has a Rosetta code account and wants to update that example, please do so.
cordially.
squeak-dev@lists.squeakfoundation.org