Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Array definition error

by RazorbladeBidet (Friar)
on Apr 15, 2005 at 15:21 UTC ( #448216=note: print w/replies, xml ) Need Help??

in reply to Array definition error

What are you trying to do?
$trainset[scalar(@trainset)] = \@inputs; $trainset[scalar(@trainset)] = \@outputs;
Is going to set the value to be \@outputs only (it will override).

So you should get 0 and 1 (the values of the outputs only) as your array elements.

Ok, nevermind, I'm thoroughly confused :)

I tested this and found the outputs to be the same except that the @trainset values are treated as strings.

$VAR1 = [ [ '0', '0' ], [ '0' ], [ '0', '1' ], [ '1' ] ]; $VAR1 = [ [ 0, 0 ], [ 0 ], [ 0, 1 ], [ 1 ] ];
"But what of all those sweet words you spoke in private?"
"Oh that's just what we call pillow talk, baby, that's all."

Replies are listed 'Best First'.
Re^2: Array definition error
by gri6507 (Deacon) on Apr 15, 2005 at 15:25 UTC
    Actually that's not true. The line $trainset[scalar(@trainset)] = \@inputs; will increase the side of the @trainset array so that when $trainset[scalar(@trainset)] = \@outputs; is called, scalar(@trainset) will be one larger and therefore not overwrite the original data. This is akin to a push.

      You statment is true. However, I'd like to ask why you are not simply using push? Does this method offer some benifit that I do not see? If so, please enlighten me.

      A truely compassionate attitude towards other does not change, even if they behave negatively or hurt you

      —His Holiness, The Dalai Lama

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://448216]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2023-03-28 21:24 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (69 votes). Check out past polls.