changeset 9332:bf6da2fbfa4e

examples/polynomial: properly handle magic colon
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 11 Jun 2009 12:37:04 +0200
parents a76f391a3d02
children 3930f8ce6430
files ChangeLog examples/@polynomial/subsasgn.m examples/@polynomial/subsref.m
diffstat 3 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jun 11 12:25:36 2009 +0200
+++ b/ChangeLog	Thu Jun 11 12:37:04 2009 +0200
@@ -1,3 +1,8 @@
+2009-06-02  Jaroslav Hajek  <highegg@gmail.com>
+
+	* examples/@polynomial/subsref.m: Handle ':' correctly.
+	* examples/@polynomial/subsasgn.m: Ditto.
+
 2009-06-11  Jaroslav Hajek  <highegg@gmail.com>
 
 	* example/@polynomial/numel.m: New method.
--- a/examples/@polynomial/subsasgn.m	Thu Jun 11 12:25:36 2009 +0200
+++ b/examples/@polynomial/subsasgn.m	Thu Jun 11 12:37:04 2009 +0200
@@ -9,7 +9,11 @@
         error ("polynomial: need exactly one index");
       else
         if (length (s) == 1)
-          p.poly(ind{1}+1) = val;
+          if (isnumeric (ind{1}))
+            p.poly(ind{1}+1) = val; 
+          else
+            p.poly(ind{1}) = val;
+          endif
         else
           error ("polynomial: chained subscripts not allowed for {}");
         endif
--- a/examples/@polynomial/subsref.m	Thu Jun 11 12:25:36 2009 +0200
+++ b/examples/@polynomial/subsref.m	Thu Jun 11 12:37:04 2009 +0200
@@ -15,7 +15,11 @@
       if (numel (ind) != 1)
         error ("polynomial: need exactly one index");
       else
-        b = a.poly(ind{1}+1);
+        if (isnumeric (ind{1}))
+          b = a.poly(ind{1}+1);
+        else
+          b = a.poly(ind{1});
+        endif
       endif
     case "."
       fld = s.subs;