Puneet, That is not an inconsistency. All in-place "side effect" operators happen, well, in-place. That should not be surprising.
Cheers, Craig On Jun 26, 2010, at 1:37 PM, P Kishor wrote: > On Sat, Jun 26, 2010 at 9:32 AM, Craig DeForest > <[email protected]> wrote: >> You are confusing direct assignment and computed assignment. "$b= >> $b*10" >> creates a new PDL and puts it in the scalar named $b, dropping the >> old one >> (and its dataflow connection to $a) on the floor. use computed >> assignment >> (".=") instead. >> > > > Fair enough. But, add this to the list of inconsistencies. > > perldl> $a = sequence 5 > perldl> p $a > [0 1 2 3 4] > > perldl> $b = $a->slice('1:3') > perldl> $b = $b + 5 > perldl> p $b > [6 7 8] > > However.... > > > perldl> p $a > [0 1 2 3 4] > perldl> > > perldl> $a = sequence 5 > perldl> p $a > [0 1 2 3 4] > > perldl> $b = $a->slice('1:3') > perldl> $b += 5 > perldl> p $b > [6 7 8] > > perldl> p $a > [0 6 7 8 4] > perldl> > > > Similar to the sin($a) working, but int($a) not working. Yes, I know > that int() is not a PDL function, but if sin(), cos(), etc. can be > expected to work, if certain arithmetic operators are expected to > work, then all of them should be expected to work. > > Consistent interfaces are the hallmark of easy to learn, effective and > powerful software. PDL is two out of three, but it would be nice for > it to be 3 out of 3. > > > > >> (Mobile) >> >> >> On Jun 26, 2010, at 8:12 AM, P Kishor <[email protected]> wrote: >> >>> perldl> $a = sequence 5, 4, 2 >>> perldl> p $a >>> [ >>> [ >>> [ 0 1 2 3 4] >>> [ 5 6 7 8 9] >>> [10 11 12 13 14] >>> [15 16 17 18 19] >>> ] >>> [ >>> [20 21 22 23 24] >>> [25 26 27 28 29] >>> [30 31 32 33 34] >>> [35 36 37 38 39] >>> ] >>> ] >>> >>> ************** >>> perldl> $b = $a->slice(':,1:2,:') >>> perldl> $b = $b * 10 >>> perldl> p $a >>> [ >>> [ >>> [ 0 1 2 3 4] >>> [ 5 6 7 8 9] >>> [10 11 12 13 14] >>> [15 16 17 18 19] >>> ] >>> [ >>> [20 21 22 23 24] >>> [25 26 27 28 29] >>> [30 31 32 33 34] >>> [35 36 37 38 39] >>> ] >>> ] >>> perldl> p $b >>> [ >>> [ >>> [ 50 60 70 80 90] >>> [100 110 120 130 140] >>> ] >>> [ >>> [250 260 270 280 290] >>> [300 310 320 330 340] >>> ] >>> ] >>> >>> So, what happened here? Why does multiplying the slice by 10 not >>> change $a as well? >>> >>> Turning on dataflow at *************** above with $a->doflow doesn't >>> help as well (although, by my understanding, it shouldn't be needed >>> >>> -- >>> Puneet Kishor >>> >>> _______________________________________________ >>> Perldl mailing list >>> [email protected] >>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl >>> >> > > > > -- > Puneet Kishor http://www.punkish.org > Carbon Model http://carbonmodel.org > Charter Member, Open Source Geospatial Foundation http://www.osgeo.org > Science Commons Fellow, http://sciencecommons.org/about/whoweare/ > kishor > Nelson Institute, UW-Madison http://www.nelson.wisc.edu > ----------------------------------------------------------------------- > Assertions are politics; backing up assertions with evidence is > science > = > ====================================================================== > _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
