view examples/code/@polynomial/subsasgn.m @ 33636:3ec6fcce7715 default tip @

gui: Avoid using HAVE_QSCINTILLA in more header files. * gui-settings.h, settings-dialog.h: Don't include QScintilla header. Forward-declare QSciLexer class instead if necessary. Declare all member functions unconditionally. * gui-settings.cc (gui_settings::get_valid_lexer_styles, gui_settings::read_lexer_settings), settings-dialog.cc (settings_dialog::update_lexer, settings_dialog::get_lexer_settings, settings_dialog::write_lexer_settings): Define functions unconditionally. * gui-preferences-ed.h: Don't include QScintilla header. Remove definition of local variable os_eol_mode from header. * gui-preferences-ed.cc (os_eol_mode): Move definition of local variable here.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 28 May 2024 14:54:58 +0200
parents a9ed4104ecfd
children
line wrap: on
line source

function p = subsasgn (p, s, val)

  if (isempty (s))
    error ("@polynomial/subsasgn: needs index");
  endif

  switch (s(1).type)

    case "{}"
      ind = s(1).subs;
      if (numel (ind) != 1)
        error ("@polynomial/subsasgn: need exactly one index");
      elseif (numel (s) != 1)
        error ("@polynomial/subsasgn: chained subscripts not allowed for {}");
      endif

      if (isnumeric (ind{1}))
        p.poly(ind{1}+1) = val;
      else
        p.poly(ind{1}) = val;
      endif

    case "."
      fld = s(1).subs;
      if (! strcmp (fld, "poly"))
        error ('@polynomial/subsasgn: invalid property "%s"', fld);
      endif
      if (numel (s) == 1)
        p.poly = val;
      else
        p.poly = subsasgn (p.poly, s(2:end), val);
      endif

    otherwise
      error ("@polynomial/subsasgn: invalid subscript type");

  endswitch

endfunction