Hi Peter,

On Fri, 9 Nov 2018 at 18:51, Peter Uhnak <i.uh...@gmail.com> wrote:
>>
>> but how do I find now the answer do I have to do something like   puzzle1  
>> stepChanges detectIndex ?
>
>
> How do you mean? It would be the same
>
> santaFloorOnBasement
>     "calculates which step take Santa to the basement"
>
>     stepChanges := input collect: [ :c |
> floor := floor + (c = '(' ifTrue: [ 1 ] ifFalse: [ -1 ]).
> floor
>     ].
>
>     stepChanges detectIndex: [ :each | each = -1 ] ifNone: [ 'invalid input 
> yo' ].
>
>> then I see this error message :  Improper store to indexable object.
>
>
> Because earlier you were comparing strings and not characters, I assumed your 
> input was an array of strings like #('(' '(' '('). but you can fix that by 
> changing `input collect:` -> `input asArray collect:` and `c = '('` -> `c = 
> $(`.

Using '(' instead of $( is indeed an error, but it isn't the cause of
the Improper store error.

Roelof, I really suggest you trigger this error again, start the
debugger and then take a look in the call stack (I'm assuming you're
familiar with at least one other programming language, so should be
able to figure out the debugger).

Cheers,
Alistair

Reply via email to