Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2020-10-24 09:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (242 votes). Check out past polls.

    Notices?