octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cell-array display in class


From: Oliver Heimlich
Subject: Re: cell-array display in class
Date: Thu, 30 Apr 2015 21:20:26 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0

On 30.04.2015 16:51, Colin Macdonald wrote:
On 30/04/15 10:19, Colin Macdonald wrote:
Other option might be leave `display` alone and change Octave to have
cell arrays render using `disp`, which can return a string (which we
then manipulate).

I created a patch, bit horrid even by my standards.  Feedback?  Should I
cleanup a little an put on Savannah?  Maybe the global variable thing is
better...

-----------------

Here's it in action:

...

Notice @infsup has no disp.m so gets a place-holder.


Colin,

the subsequent indentation of the disp output is not going to work. It will break console output if lines get very long. “disp” takes the console width into account when it creates its output. When you add spaces later on, you effectively decrease console width. Thus, the class method needs to know the current level of indentation!

You can have a look at the development version of the interval package. You can make it run from source using “make run”, alternatively install the development version for loading the package using “make install”.

I have added a disp.m function, which communicates with display.m using a global variable. Formatted output works for cell arrays without nesting. The indentation is wrong within nested cell arrays. The code is still experimental.

>> {infsup(magic (11))}
ans =
{
  [1,1] = 11×11 interval matrix

   Columns 1 through 6:

      [68]    [81]    [94]   [107]   [120]     [1]
      [80]    [93]   [106]   [119]    [11]    [13]
      [92]   [105]   [118]    [10]    [12]    [25]
     [104]   [117]     [9]    [22]    [24]    [37]
     [116]     [8]    [21]    [23]    [36]    [49]
       [7]    [20]    [33]    [35]    [48]    [61]
      [19]    [32]    [34]    [47]    [60]    [73]
      [31]    [44]    [46]    [59]    [72]    [85]
      [43]    [45]    [58]    [71]    [84]    [97]
      [55]    [57]    [70]    [83]    [96]   [109]
      [56]    [69]    [82]    [95]   [108]   [121]

   Columns 7 through 11:

      [14]    [27]    [40]    [53]    [66]
      [26]    [39]    [52]    [65]    [67]
      [38]    [51]    [64]    [77]    [79]
      [50]    [63]    [76]    [78]    [91]
      [62]    [75]    [88]    [90]   [103]
      [74]    [87]    [89]   [102]   [115]
      [86]    [99]   [101]   [114]     [6]
      [98]   [100]   [113]     [5]    [18]
     [110]   [112]     [4]    [17]    [30]
     [111]     [3]    [16]    [29]    [42]
       [2]    [15]    [28]    [41]    [54]

}

Oliver



reply via email to

[Prev in Thread] Current Thread [Next in Thread]