octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #53906] Cannot make an object array with squar


From: Andrew Janke
Subject: [Octave-bug-tracker] [bug #53906] Cannot make an object array with square brackets
Date: Wed, 14 Aug 2019 01:16:14 -0400 (EDT)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0

Follow-up Comment #9, bug #53906 (project octave):

Yep. Here's the hack I use in Packajoozle
(https://github.com/apjanke/octave-packajoozle):

An "objvcat" function for "OBJect Vector conCATenation":



## -*- texinfo -*-
## @deftypefn {Function File} {@var{out} =} objvcat (@var{x}, @dots{})
##
## Concatenates object array vectors.
##
## This function just papers over the fact that Octave does not support
## the @code{[obj1 obj2]} concatenation syntax for objects.
##
## @var{x} may be an object of any type. The additional inputs may be any
## type that is assignment compatible with @var{x}, but they will typically
## just be more objects of the same type.
##
## @end deftypefn


function out = objvcat (varargin)
  # Hack to concatenate object vectorss because Octave doesn't support it as
of 5.1
  #
  # The "v" in "objvcat" is for "vector" concatenation, not "vertical".
  out = [];
  for i_arg = 1:numel (varargin)
    B = varargin{i_arg};
    if isempty (out)
      out = B;
    else
      for i_B = 1:numel (B)
        out(end+1) = B(i_B);
      endfor
    endif
  endfor
endfunction


And an "objcatc" function for "OBJect conCATenation from Cells":


    function out = objcatc (c)
      %OBJCATC Hack to allow one-liners like objcatc({myobj.propname})
      mustBeA (c, "cell");
      out = objvcat (c{:});
    endfunction



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?53906>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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