From bug-octave-request at bevo dot che dot wisc dot edu Fri Jan 15 11:40:15 1999 Subject: Re: [lost mail? ]`list' behaviour different in octave-2.1.10 and2.1.12 From: "A. Scottedward Hodel" To: Joao Cardoso CC: bug-octave at bevo dot che dot wisc dot edu Date: Fri, 15 Jan 1999 11:39:11 -0600 (CST) John and I hashed this over a bit when he added the list data structure. The problem is a discrepancy in 2.1.10 between what happens when you say a = list(...) x = a(2) x = a([2 3 4]) 2.1.12 returns a list for both of these, while 2.1.10 returns a the list value for the first. That can lead to lots of irritating problems when doing list operations, since if an index vector drops to length 1 you get a value instead of a list with a single value. The new list function "nth" replaces the singleton case: x = nth(a,2) will do what you want, and allows the above list operations to consistently return lists, even if there's only one item in the list. I think the matlab cell structure requires a similar kind of operation, but I haven't used it in several months so I don't recall the details. A S Hodel Assoc. Prof. Dept Elect Eng, Auburn Univ,AL 36849-5201 On leave at NASA Marshall Space Flight Center (256) 544-1426 Address:Mail Code ED-13, MSFC, Alabama, 35812 http://www.eng.auburn.edu/~scotte ---------- >From: Joao Cardoso >To: John Eaton >Subject: [lost mail? ]`list' behaviour different in octave-2.1.10 and 2.1.12 >Date: Fri, Jan 15, 1999, 10:53 AM > >------- start of forwarded message ------- > >[Some days ago I sent this e-mail that seems to be lost; I resent it >here again] > >[I think the problem was that your address on the list was >jcardoso at bart dot inescn dot pt, but this message came from >jcardoso at inescn dot pt dot I changed your address on the list and am >reposting the message for you. The odd thing is that SmartList did >not notify me that the message had not been posted. Hmm. --jwe] > >Hi, > >In octave-2.1.10 one could retrive an element from a list and use it as >normal variable. This behaviour has been changed in octave-2.1.12. Is >this deliberate? If it is, I can't see how to use lists... > >In 2.1.10: > > octave-2.1.10:1> a=list(1,2,3); > octave-2.1.10:2> a(2)*3 > ans = 6 > >in 2.1.12: > > octave-2.1.12:1> a=list(1,2,3); > octave-2.1.12:2> a(2)*3 > error: binary operator `*' not implemented for `list' by `scalar' >operations > error: evaluating binary operator `*' near line 2, column 5 > octave-2.1.12:2> t=a(2) > t = > ( > [1] = 2 > ) > octave-2.1.12:3> t*2 > error: binary operator `*' not implemented for `list' by `scalar' >operations > error: evaluating binary operator `*' near line 3, column 2 > octave-2.1.12:3> > >This happens also for matrices. > >Thanks, >Joao > >-- >Joao Cardoso, INESC | e-mail: >R. Jose Falcao 110 | tel: + 351 2 2094345 >4050 Porto, Portugal | fax: + 351 2 2008487 >