I would check this in Pharo, but have so far failed to get it running under
Ubuntu 17.10.
Squeak _is_ running there, sort of, and the definition of #permutationsDo:
in Interval
is this code:
permutationsDo: aBlock
"Repeatly value aBlock with a single copy of the receiver. Reorder the copy
so that
I'm reading this in gmail. After "this method work:" I see a gap with
nothing visible.
After "wich looks like this" there is again a gap with nothing visible.
Recalling that the Life universe is an *infinite* two-dimensional space,
you want a data
structure that naturally grows to be as big as it
using a rectangular
matrix
for Life. I might possibly use a quad tree, but I'd probably stick with a
set of points.
On 16 January 2018 at 19:41, Richard O'Keefe wrote:
> I'm reading this in gmail. After "this method work:" I see a gap with
> nothing visible
"I have a SortedCollection of Teams. Now I need to convert *it*
to a line like ...".
Well, no. You need to convert *each team* separately to such a
line. So something like
aStream nextPutAll: '...header line...'; cr.
mySortedTeams do: [:eachTeam |
-write a formatted line describing eac
As you noted, wrapping going forward:
seq at: index \\ seq size + 1
Wrapping going backward is nearly as easy:
seq at: (index - 2) \\ seq size + 1
This would not work with #rem:
On Fri, 29 Mar 2019 at 04:13, Tim Mackinnon wrote:
> Hey guys - I’m wondering if someone might have a nice way of se
This loop is a special case.
size := 10.
prevIndex := size. prevValue := seq at: prevIndex.
thisIndex := 1.thisValue := seq at: thisIndex.
nextIndex := 2.nextIndex := seq at: nextIndex.
[thisIndex <= size] whileTrue: [
...
prevIndex := thisIndex. prevValue := thisValue.
thisIndex := n
If a Smalltalk system did have a "cyclic" indexing
method that did "self at: (index - 1) \\ self size + 1",
where would it be?
Since it makes sense for all and only sequences,
we'd expect it to be in SequenceableCollection.
Since it is like #at:, and #at: is an 'accessing'
method, we'd expect to fi
Question 1. Should that be #asDictionary?
Question 2. If not, what's a Dictonary?
Question 3. I see you are using self-encapsulation,
with a getter 'self robot'
and a setter 'self robot: something'.
Of course that means that outside code
can fr
t. I don't think I've ever written a program
where that was a good idea.
On Sun, 31 Mar 2019 at 19:55, Roelof Wobben wrote:
> Op 31-3-2019 om 03:47 schreef Richard O'Keefe:
>
> Question 1. Should that be #asDictionary?
>
>
>
> yes, it does.
>
I have Pharo 6.1 and Pharo 7.0 working in Ubuntu 18.04
with no trouble so far. I just downloaded the launcher
from pharo.org and pulled the images down that way.
One thing I do find annoying in Ubuntu 18.04 is the
number of programs (like okular) that spew warning
messages out the terminal. Phar
I tested with minidebian and
> it also failed.
>
> Richard, was you able to use Iceberg? It should only work if either Ubuntu
> fix this dependency problem with libcurl or Pharo started to use libcrl4.
>
>
>
> On Tue, Apr 2, 2019 at 5:50 AM Richard O'Keefe wrote:
>
For a change this is an exercism problem I know something about.
I did look at the exercism web site, and did all the SML exercises,
but could not find any for Smalltalk or Pharo.
The exercise is in fact about using a stack.
stack <- empty
for each character of the string
if it is one
installed without conflict.
On Thu, 4 Apr 2019 at 01:34, Ben Coman wrote:
>
> On Wed, 3 Apr 2019 at 05:09, Richard O'Keefe wrote:
>
>> I just did a complete reinstall of Ubuntu 18.4 on this
>> laptop yesterday,
>>
>
>
>
>> and it did not come with any
VisualAge Smalltalk has, in addition to the standard #on:do:,
#when:do:, ..., #when:do:#when:do:#when:do:#when:do:#when:do:,
with the last four mapping to #whenOneOf:doMatching:, taking
two arrays.
It's easy enough to add your own methods like
on: exn1 do: act1 on: exn2 do: act2
"An imperfect
It would really REALLY **REALLY** help if we knew what
the heck you were trying to do. There is an excellent
chance that it is MUCH simpler than you think. If you
cannot show us the Smalltalk version of the problem,
can you show us the version for some other language?
On Sun, 7 Apr 2019 at 20:1
dispath first the direction North, East, South, West
> and then use double dispatch to find the right move.
>
> Roelof
>
>
>
>
>
> Op 8-4-2019 om 06:50 schreef Richard O'Keefe:
>
> It would really REALLY **REALLY** help if we knew what
> the heck you were
Remember, we cannot see the Smalltalk exercises in exercism.
We cannot help you without knowing what problem you are
trying to solve. Is this problem basically the same as
https://www.reddit.com/r/dailyprogrammer/comments/3ntsni/20151007_challenge_235_intermediate_scoring_a/?ref=share&ref_source=l
ruct might be used to obtain the same as the
> #when:do:when:do: but using a chained approach instead.
>
> Regards,
>
> [1] AFAIR when I used VAST (+a decade ago) it didn't have "ANSI"
> exceptions.
>
> Esteban A. Maringolo
>
> El lun., 8 abr. 2019 a las 0:49, Richard O
a Robot which can turn left, turn right or moveForward.
>>
>> now I have a string like 'LAR'
>>
>> that means the robot needs to turn left (l) , move forward one place (A)
>> and turn left.
>> and I have to keep track to which direction the robot i
x27; -> 0;
> yourself);
> yourself)
>
>
> but I cannot come to the same outcome with this code :
>
>
> pointToName: aPoint
> ^aPoint x isZero
> ifTrue: [aPoint y > 0 ifTrue: [#north] ifFalse: [#south]]
>
le problems like this.
>
> Out of coriousy what dialect do you use?
>
>
> Op 8-4-2019 om 17:11 schreef Richard O'Keefe:
>
> You are expected to use my code fragments for *ideas*,
> not to incorporate them *literally* in your code. As
> I explained, *without seeing t
You wrote: "a frame is always two times a throw"
but the specification says "A frame is composed of one or two ball throws"
and later we learn that the 10th frame may have three throws.
There is an issue with your Smalltalk.
aCollection withIndexDo: [:index :item |
"You have the arguments in th
gt;>>> and I think I need then to use if then , which I try to avoid as much
>>>> as possible.
>>>>
>>>> Roelof
>>>>
>>>>
>>>>
>>>> Op 18-4-2019 om 18:33 schreef Richard Sargent:
>>>>
>>
Let me tell you a story.
The story is about someone I knew back when I was doing my MSc.
He was really bright, but he had to repeat a year in the papers
part of his MSc.
Why? Because he didn't get statistics.
Differential equations? No problem.
Topology? No problem.
Operations research (which wa
Ben Coman wrote:
> On Mon, 22 Apr 2019 at 23:15, Richard O'Keefe wrote:
> >
> > I already discoursed on this at some length.
> > (1) In my own answer, I used code to map direction names to vectors.
> > But the Dictionary answers are absolutely fine.
> > (2)
be later I come back when I have a beter understanding what Object
> Oriented is and how I can use it to solve more difficult problems.
>
> Roelof
>
>
> Op 24-4-2019 om 18:07 schreef Ben Coman:
> > On Wed, 24 Apr 2019 at 16:52, Richard O'Keefe wrote:
> >> The o
PS: in this thread nobody has disagreed about what OO programming is.
The disagreement was about *how to apply it*.
There actually seems to be quite a lot of agreement that the
answer depends on what your underlying goal is:
- is this throw-away code for a specific problem?
- is this code to be i
he
> problems. Because smalltalk is OO I sometimes look at ruby code to see
> how they solve things.
>
> Roelof
>
>
>
>
>
> Op 25-4-2019 om 06:23 schreef Richard O'Keefe:
>
> PS: in this thread nobody has disagreed about what OO programming is.
> The disag
Branching as such is not a sign of bad design in OOP.
The actual dogma is that *testing the class of an
argument instead of dispatching* is a sign of bad design.
Just consider the case of binary search. That is not
the kind of branching that lends itself to dynamic
dispatch. Nor is the kind of br
One point worth making is that Python lambdas are artificially restricted:
the body of a Python lambda may only be a single expression, not a sequence
of statements. This restriction is for ideological reasons (the BDFL does
not *want* you to do that) not for technical reasons. Lisp and Algol 68
Suppose you want a pair of mutually recursive functions.
They have to be able to name each other.
In languages like Python and Ruby, you can have
methods AND you can have named functions. In fact
Python had named functions before it had objects.
But in Smalltalk, you have methods, which cannot be
I do wish people wouldn't say "beg the question"
https://grammarist.com/rhetoric/begging-the-question-fallacy/
when they mean "invites" or "raises" the question. Sigh.
Yes, Smalltalk is just like Lua here.
|f g| "declare f and g as local variables"
f := [... g value ...]. "f uses g's current
stream := WriteStream on: (String new: gifts size * "estimated size per
gift" 10).
"The number after #new: is the *initial* allocation; the stream will
reallocate it
as needed."
gifts allButLastDo: [:each |
stream nextPutAll: each; nextPutAll: ', '].
stream nextPutAll: 'and '; nextPutAll: gifts
Blocks in current Smalltalk system are just like lambdas in Scheme.
Pharo even has continuations (see the Continuation class).
On Fri, 17 May 2019 at 05:21, Brainstorms wrote:
> I beg your pardon.. and thank you for being the first to draw my attention
> to
> the fact that the phrase (a common
I did not mean "course of instruction on the topic of continuations",
I meant "that class whose name is Continuation in the Smalltalk image."
In a Playground, type Continuation and then Control-B.
On Fri, 17 May 2019 at 14:03, Brainstorms wrote:
> Richard O'Keefe
This is not an answer to your question, but it is an observation by someone
who was trying all
the exercises. As a user, it was just working. Then suddenly, there was a
change. Instead of
a new exercise popping up underneath Exercism, it would appear as
Exercise@Foobar. No big
deal. What *is*
If you want to move around in strings, you might want to use a ReadStream.
In some Smalltalk systems there is a method called #skipToAll:.
Here's how mine starts out:
skipToAll: aSequence
"If the remaining elements can be parsed as ,
return true leaving the position where? Otherw
I forgot to mention that in order to be able to translate XPath to Smalltalk
I added these methods to my Smalltalk:
AbstractSequence>>
afterSubCollection: aSequence [ifAbsent: exceptionBlock]
"based on substring-after"
beforeSubCollection: aSequence [ifAbsent: exceptionBlock]
"based on
t to take some lines from the end
> of a class comment and use them in an exercism exercise - but its not
> different than many applications - find some tag and use the text after it.
> I”m kind of surprised its not in Pharo.
>
> Tim
>
>
> On 1 Jun 2019, at 12:25, Richard
uot;
^self match: aCollection
Sorry about the incomplete message.
#match: is such a bad name for this operation that the method comment has to
go to some trouble to explain that it is nothing like #match: for Strings.
On Sun, 2 Jun 2019 at 14:29, Richard O'Keefe wrote:
> To get #s
already.
>
> Note that most current implementations of #upToAll: already use words like
> match, so #match: is not that crazy.
>
> Yes it should be possible to talk about naming, but just adding aliases,
> no.
>
> My opinion, of course.
>
> > On 2 Jun 2019, at 04:33,
There was a thread about this two years ago.
http://forum.world.st/Smalltalk-Internet-Browser-td4944879.html
There is Scamper for Squeak, https://github.com/HPI-SWA-Teaching/Scamper
It used to come standard in Squeak. When I knew it, it couldn't quite
handle HTML 3.2. I imagine it was removed f
Great tool. Helpful video.
One thing would improve the video: remove the sound track, or
replace it with spoken commentary.
On Fri, 12 Jul 2019 at 04:15, Torsten Bergmann wrote:
> Hi,
>
> I updated my MessageFlowBrowser today to work on Pharo 7 and 8, see
> attached screenshot
> or youtube vid
Search trees (which come in many varieties) are good for collections in
which
adding, deleting, and lookup are interleaved, where there is an order on the
elements (if used as a set) or the keys (if used as a dictionary). So are
hash tables. But (balanced) search trees have guaranteed O(lg n) wor
I've been pondering this reply for a while.
There are so *many* kinds of tree.
There are rooted trees (very popular in computing) and unrooted trees (what
you get from some phylogenetic reconstructions and of course the spanning
tree of a graph).
There are trees with and without parent links.
There
To a very good approximation, Smalltalk doesn't copy anything unless you
ask it to.
In this respect it's just like Java, Python, Ruby, ECMAScript, and most OO
languages.
C++ *does* like to copy things, but it is unusual.
On Thu, 25 Jul 2019 at 00:46, sergio ruiz wrote:
> I think my understandin
Comment 1.
You probably meant to write
tracks: aCollection
^tracks := aCollection
Comment 2.
This is a poor design. As it is, any object can replace the tracks of an
artist
with *anything*. And even without doing that, any object can add and
remove
items to an artist's tracks,
There are some spelling issues in the PDF one finds at the Newton-Raphson
link.
"bellow" and "below" mean different things and sound quite different
(BELL-owe vs b'-LOW). In "In the sketch bellow" the one you want is
"below".
"bloc" and "block" sound the same but also mean different things, and
th
Nice enough, but where is the canticle?
On Tue, 6 Aug 2019 at 03:20, Richard Kenneth Eng
wrote:
> A big fan of my work created this rogue video:
> https://drive.google.com/file/d/1opveHaukFK8WbQ8wg8b14wuKJsjoOZfO/view
>
> I appreciate the homage, but I can't take credit for it.
>
> It's really q
The ANSI Smalltalk standard is characteristically vague here.
Both the memmove and memcpy readings are consistent with it.
The standard is characteristically buggy here too: the two
lines I've flagged with ** disagree. I take the second one
to be correct.
5.7.12.5 Message:
replaceFrom: start t
What did you expect
transaction = Transactions new.
to do, besides computing the answer 'false' and throwing it away?
On Fri, 16 Aug 2019 at 22:38, Roelof Wobben wrote:
> Hello,
>
> I try now to make this challege work on Pharo which is orginal a c#
> problem to practice OOP.
>
> The challe
What is the source of the challenge?
Is there a version in English?
I am having very serious trouble trying to make sense of
"your bank accounts can have multiple accounts for money".
I note that in your C# code a customer has an ID, a first name,
and a last name. There is nothing about this in t
https://github.com/rwobben/bankaccount
points to a repository with C# code, so I cannot comment on the Smalltalk.
There is, however, a striking thing about the C# code, qua C#, that is
worth mentioning.
It is not encapsulated.
Let's start with the most obvious one.
A bank account has a password,
gned thereafter.
> Delete that setter.
Customer >> AddBankAccountToCustomer: bankaccount [
bankaccounts add: bankaccounts.
]
On Sat, 17 Aug 2019 at 21:59, Roelof Wobben wrote:
> Sorry, then a pointed to a wrong repo
> this is the repo with smalltalk code :
>
> https://
I think some people are taking this a bit too seriously.
This particular example cannot be taken seriously as an
approximation of a real bank, and the "credentials"
need not be anything other than a simple clear-text string.
There is, for example, *NO* interface of any kind (UI or
API) anywhere in
The second ofthose links ends with
"These topics will be covered in the next episode."
Anyone know where the next episode is?
On Thu, 22 Aug 2019 at 23:32, Vitor Medina Cruz
wrote:
> Thanks! It seems there are mostly nomenclature changes, I will try to
> continue with the book and with those two
Distinguishing between "pull-based" and "push-based" streams in
Smalltalk makes no sense, because
do: aBlock
[self atEnd] whileFalse: [aBlock value: self next].
is in the same protocol in the ANSI standard
as #atEnd and #next, and in most Smalltalk systems it is in
Stream. There should n
Here's what I think.
copyFrom: start to: stop
" ANSI Smalltalk section 5.7.8.7, reorganised a bit.
Answer a new collection containing all of the elements of the
receiver between the indices start and stop inclusive in their
original order. The element at index start in the receiver
s not respect the ANSI
semantics of #copyFrom:to:. Example:
'abc' copyFrom: 6 to: 0
should, according to the common specification, answer ''.
The result is instead a primitive failure in #basicNew:, of
all things.
On Mon, 2 Sep 2019 at 20:37, Richard O'Keefe wrot
Ad 1.
To cut a long story short,
the ANSI Smalltalk standard is the nearest thing we have to a clear
specification
of the nearest thing we have to a consensus.
One of the reasons that Smalltalk gets less use than many of us would
like
is that it can be extremely unpleasant trying to
I refrain from expressing an opinion about any kind of weapon here.
I would hope that in a civilised society anyone could casually mention
any legal activity they engage in without being subjected to harassment.
For what it's worth, I have created a GitHub site for my Smalltalk
system, but there's
The difference in behaviour is exactly what I would expect.
I can't think of any way to make
aSet collect: collectBlock thenDo: doBlock
act identically to
(aSet collect: collectBlock) do: doBlock
without creating an intermediate set.
Here, for example, is the definition in Smalltalk/X,
with commen
(1) If you want (aSet collect: collectBlock) do: doBlock
you can write exactly that. Nothing stops you, and it will
be as clear and reliable as any use of Set>>collect:, which
is to say NOT VERY CLEAR OR RELIABLE AT ALL.
(2) #collect:then{Do:Select:Reject:} had no other purpose than
with most collection classes.
* does nothing to improve performance but just adds overhead.
Are we done yet?
On Tue, 10 Sep 2019 at 01:27, David T. Lewis wrote:
> On Mon, Sep 09, 2019 at 05:46:48PM +1200, Richard O'Keefe wrote:
> >
> > (3) Oddly enough, the reason that #coll
utomatic refactoring rule that
> consolidates chained #collect: and #do: sends into a faster
> #collect:thenDo: send without breaking existing code.
>
> Am .09.2019, 07:46 Uhr, schrieb Richard O'Keefe :
>
> > (1) If you want (aSet collect: collectBlock) do: doBlock
> >
I think it's fair to say that #<< *is* a bug.
There does not seem to be any coherent description of what it means.
It's overloaded to mean *either* #nextPut: *or* #nextPutAll: *or*
something else, in some confusing ways.
CommandLineHandler #nextPutAll: (sent somewhere else)
Integer
It is good that you have a coherent idea of how << can work.
The question I was addressing is how << *DOES* work in Pharo.
Having simple things working, if they are kept consistent,
is indeed good. The problem is that in Pharo 7 they are NOT
consistent, and << does NOT work consistently, because t
to something they already know is a Symbol.
For what it's worth, I've attached my implementation.
On Wed, 11 Sep 2019 at 21:46, Herby Vojčík wrote:
> On 11. 9. 2019 3:23, Richard O'Keefe wrote:
> > It is good that you have a coherent idea of how << can work.
>
&
There are some aspects of the "Covenant" that rub me up the wrong way.
I note that the only part of it where anyone actually promises to do
(or not do) anything is the "Pledge", which rather pointedly refrains
from treating people with different political viewpoints (like gun
ownership, or like TER
There was a point raised in the Ruby discussion (where my thoughts about
Matz changed from "inventor of a language that filled a much-needed gap" to
"really thoughtful so maybe I was wrong about Ruby") which I think is
sufficient reason for a major revision to the Coraline Code. (For the
record, I
Correspondents should be warned that the phrase "safe spaces" needs a
trigger warning.
I am not joking here. People who are genuinely sensitive to the
perceptions and
concerns of others really should avoid that concept because there are many
people in
whom it arouses strong negative feelings. Who
You just wrote what I didn't quite dare to say.
Thank you.
On Wed, 18 Sep 2019 at 11:29, Ramon Leon wrote:
> On 2019-09-17 2:34 p.m., Offray Vladimir Luna Cárdenas wrote:
> > as I say the important issue is to provide safe
> > spaces via explicit or implicit rules
>
> I understand, I just disagr
On the whole, the new code is pretty good.
There was one thing that troubled me, though:
"even outside of Pharo's public communication channels."
What business is it of the Pharo Board what anyone says in any
other community? I've heard too many cases where A says something
to B and C complains a
Thank you Craig Latta. I see there is a caffeine.js.org/pharo
"This page is an early demo of running Pharo 6 with the SqueakJS
virtual machine. It gets far enough now that I think several people in
the Pharo community could fix the rest of the bugs (mostly missing
primitives). "
I'm trying it but
PS: After several minutes, the progress bar for "Loading app Pharo..."
stopped moving.
So I don't think I'll bother trying Pharo on a tablet yet...
On Sun, 22 Sep 2019 at 22:15, Richard O'Keefe wrote:
>
> Thank you Craig Latta. I see there is a caffeine.js.org
I am developing a Smalltalk interface to an existing C library which I
intend to make generally available. Naturally I am doing this in my own
Smalltalk system first, where it's unsurprisingly easy for me. But when
I have it working, I'd like to make a Pharo port available.
I have never used the
This is not a question of left vs right. It's a question of
authoritarian vs libertarian.
And this is very relevant to the community.
It's also not a question of democracy vs central authority.
It's a question of vs παρρησία vs goodspeak.
And this is very relevant to the community also.
Pharo is
This is perhaps the biggest question I've faced working on my own Smalltalk,
and it is connected to an annoyance.
My answer is that when I am *using* library code, I want my mistakes
to be detected
at "interface" level. If, for example, I do
((1 to: 5) asOrderedCollection) at: 2.5 put: #fred; you
Thank you for that. I note that some sections have nothing in them.
Now that I have
read that, what is the next thing to read? In particular, how do I
connect C numeric
types introduced by the library to FFI?
On Mon, 23 Sep 2019 at 16:45, Tomaž Turk wrote:
>
> Hi,
>
> The book draft is here:
>
On Mon, 23 Sep 2019 at 16:49, Vince Refiti wrote:
> The SQLite3 API is very well documented, and the UDBC-SQLite3 project
> (https://github.com/astares/Pharo-UDBC) is a nice and clean binding to it.
> Look in UDBCSQLite3Library class.
Thanks. It's nearly midnight here; I've downloaded it and
What I want to do is to create a binding for the SoftPosit library.
A typical function has an interface like
quire16_t q16_fdp_add(quire16_t, posit16_t, posit16_t);
where
typedef struct { uint16_t v; } posit16_t;
typedef struct { uint64_t v[2]; } quire16_t;
A "quire" is a do
Let's look at some official numbers.
Looking at
https://www.hesa.ac.uk/news/11-01-2018/sfr247-higher-education-student-statistics/qualifications
we see that overall, female graduates outnumbered male graduates about
4 to 3 in each of the three years
recorded. The imbalance in science graduates w
The interface should surely be
SomeClass
methods for: 'compression'
zipped "return a byte array"
class methods for: 'decompression'
unzip: aByteArray "return an instance of SomeClass"
ss in your examples, I think you will see why the chosen interface was
> used.
>
> Peter Kenny
>
>
> -Original Message-
> From: Pharo-users On Behalf Of Richard
> O'Keefe
> Sent: 03 October 2019 23:08
> To: Any question about pharo is welcome
> Subjec
VT_DECIMAL sounds like a very close match to ScaledDecimal.
Or it would if ScaledDecimal were consistently implemented between Smalltalks.
The intent behind ScaledDecimal in the ANSI Smalltalk standard appears to
have been an (m,p) representation where m and p are Integers standing for
m * 10^p, fo
Whoops, Visual Age uses 17 BYTES, not 17 BITS. Slaps own wrist.
On Wed, 9 Oct 2019 at 22:03, Richard O'Keefe wrote:
>
> VT_DECIMAL sounds like a very close match to ScaledDecimal.
> Or it would if ScaledDecimal were consistently implemented between Smalltalks.
> The intent beh
ctating
> a single way to do so, if I understand it correctly.
>
> The composition with several messages allows for end users to choose their
> own encoding format, depending on their own needs, which I think is more
> flexible.
>
> Sven
>
> > On 4 Oct 2019, at 06:3
days keysAndValuesDo: [:key :value |
Transcript print: key; nextPutAll: ' has '; print: value;
nextPutAll: ' days'; cr].
Transcript endEntry.
works too and in some Smalltalks is easily the most efficient approach, as it
does not construct any strings you have no other use for.
In Pharo, howeve
It may be worth noting that the 1998 ANSI Smalltalk standard defines
#asString for
Character, , String, and Symbol and for those classes only.
VisualWorks extends #asString to things like Filename and URIs and Text and
several other things for which "convert to String" makes sense and are not
local
(1) Be very clear in your design about which objects are shared and
which are not.
(2) Immutable objects can be shared safely. Mutable ones are much
much harder to work with.
(3) Lazy initialisation does not work well in concurrent programming,
*except* when you are
constructing an immutable
First, this is presumably the "Die" exercise from the Pharo track of
exercism.io.
Second, this is a case where
- there is nothing to a Die other than the number of faces,
so from a practical point of view there should not be a Die class;
- there is nothing to a DieHandle other than a sequence
When is it pointless to introduce a WriteStream and just use #, ?
When #, would not be in a loop or recursion.
Constructing error messages, class initialisation code, that sort of thing.
If you find yourself doing a lot of concatenations, you are probably
missing an abstraction. For example, buil
No kind of object does what you want.
You cannot do 3 3
or #x #y
As for [:x | x + 1] 3, what would be the *point* of doing this?
What is the block suppose to *do* with the 3? Do you want to extend this
to [:x :y | x + y] 3 4 ? If not, why not? What about [3+4] "what to put
The first question you should ask is "What do I expect #ball asUppercase to be?"
The ANSI Smalltalk standard says
5.7.10.9 Message: asUppercase
Synopsis
Answer a new string which contains all of the elements of the
receiver converted to their upper
case equivalents.
Definition:
Answer a new s
l times but I do not see the reason.
>
> Roelof
>
>
>
> Op 30-10-2019 om 01:38 schreef Richard O'Keefe:
> > The first question you should ask is "What do I expect #ball asUppercase to
> > be?"
> > The ANSI Smalltalk standard says
> > 5.7.10.9
Myself, I see only one issue in your code, and that is the pointless
use of sqrt.
scoreX: anInteger y: anInteger2
| radiusSquared |
radiusSquared := anInteger squared + anInteger2 squared.
radiusSquared > 100
ifTrue: [ ^ 0 ].
radiusSquared > 25
ifTrue: [ ^ 1 ].
r
You know, this is an area where style opinions differ a lot.
What the message is suggesting you try is
aString splitOn: [:each | ' -_' includes: each]
That's all. No need for anything more complicated.
But there is a trade-off. Clarity vs efficiency. You should make your
code clear and correct
Time microsecondsToRun: [
|n|
n := (2 raisedToInteger: 8 * 8) - 1.
Transcript
nextPutAll: 'The number of grains on an 8x8 chessboard is ';
print: n; cr; endEntry].
On my laptop, this reports 194 microseconds.
Why would you use recursion, anyway?
Time microsecondsToRun: [
ld check for
> that and for the total I do not need that part.
>
> Roelof
>
>
>
> Op 5-1-2020 om 13:58 schreef Richard O'Keefe:
> > Time microsecondsToRun: [
> > |n|
> > n := (2 raisedToInteger: 8 * 8) - 1.
> > Transcript
> >
ay.
>
> That said, any solution will do. Your advice on alternative considerations
> is insightful and always good to read.
>
> cheers -ben
>
> On Mon, 6 Jan 2020 at 00:25, Richard O'Keefe wrote:
>>
>> I did not ask why you were validating input.
1 - 100 of 383 matches
Mail list logo