Re: [Pharo-users] mentor question 2.

2020-04-28 Thread Richard O'Keefe
String>> isValidBinary ^self allSatisfy: [:each | each = $0 or: [each = $1]] binaryToDecimal "The caller should ensure that self isValidBinary before calling this." ^self inject: 0 into: [:acc :each | acc*2 + (each codePoint - $0 codePoint)] On Mon, 27 Apr 2020 at 06:05,

Re: [Pharo-users] mentor question 2.

2020-04-27 Thread Richard Sargent
On Sun, Apr 26, 2020 at 10:11 AM Roelof Wobben via Pharo-users < pharo-users@lists.pharo.org> wrote: > Hello, > > I have to make some code that convert a binary to a decimal and im not > allowed to use the convert methods that Pharo has. > > So I have written this : > > > decimalFromBinary:

Re: [Pharo-users] mentor question 2.

2020-04-27 Thread Roelof Wobben via Pharo-users
  From: Pharo-users On Behalf Of Roelof Wobben via Pharo-users Sent: 27 April 2020 12:23 To: pharo-users@lists.pharo.org Cc: Roelof Wobben Subject: Re: [Pharo-users] mentor question 2

Re: [Pharo-users] mentor question 2.

2020-04-27 Thread PBKResearch
Of Roelof Wobben via Pharo-users Sent: 27 April 2020 12:23 To: pharo-users@lists.pharo.org Cc: Roelof Wobben Subject: Re: [Pharo-users] mentor question 2. Op 27-4-2020 om 13:16 schreef PBKResearch: Roelof You maybe have enough mentors already, but there are some important features

Re: [Pharo-users] mentor question 2.

2020-04-27 Thread Roelof Wobben via Pharo-users
] mentor question 2.   Op 26-4-2020 om 20:17 schreef Sven Van Caekenberghe: >  >> On 26 Apr 2020, at 20:10, Gabriel Cotelli <g.cote...@gmail.com> wrote: >>  >> In the first method y

Re: [Pharo-users] mentor question 2.

2020-04-27 Thread PBKResearch
. Peter Kenny From: Pharo-users On Behalf Of Roelof Wobben via Pharo-users Sent: 26 April 2020 19:52 To: pharo-users@lists.pharo.org Cc: Roelof Wobben Subject: Re: [Pharo-users] mentor question 2. Op 26-4-2020 om 20:17 schreef Sven Van Caekenberghe: > >> On 26 Apr 2020,

Re: [Pharo-users] mentor question 2.

2020-04-26 Thread Roelof Wobben via Pharo-users
--- Begin Message --- Op 26-4-2020 om 20:17 schreef Sven Van Caekenberghe: On 26 Apr 2020, at 20:10, Gabriel Cotelli wrote: In the first method you aren't doing an assignment, are sending the message = to the temp isValid, if you change the method to: decimalFromBinary: aString |

Re: [Pharo-users] mentor question 2.

2020-04-26 Thread Sven Van Caekenberghe
> On 26 Apr 2020, at 20:10, Gabriel Cotelli wrote: > > In the first method you aren't doing an assignment, are sending the message = > to the temp isValid, if you change the method to: > decimalFromBinary: aString > | result isValid | > isValid := self isValidBinary: aString. >

Re: [Pharo-users] mentor question 2.

2020-04-26 Thread Gabriel Cotelli
In the first method you aren't doing an assignment, are sending the message = to the temp isValid, if you change the method to: decimalFromBinary: aString | result isValid | * isValid := self isValidBinary: aString.* isValid ifTrue: [ result := 0. aString

[Pharo-users] mentor question 2.

2020-04-26 Thread Roelof Wobben via Pharo-users
--- Begin Message --- Hello, I have to make some code that convert a binary to a decimal and im not allowed to use the convert methods that Pharo has. So I have written this : decimalFromBinary: aString     | result isValid |     isValid = self isValidBinary: aString.     isValid