Problems with map.



Map normally obeys the 'inflag' setting (with default = false):

      map(f,1/x) => f(1)/f(x)
      [op(1/x), args(1/x)]  => ["/", [1,x] ]
      block([inflag:true], map(f,1/x) ) => f(x)^f(-1)
      block([inflag:true], [op(1/x), args(1/x)]  ) => ["^", [x, -1]]

But not in the case of rational numbers -- even though op/args *even with
inflag:true* -- are treated as *e.g.* 2/3 == "/"(2,3).

This is documented in the mapatom function (which should be cross
referenced by the doc for "map" but isn't), which defines whether something
is considered atomic by "map", but I agree that it is bizarre.

The obvious solution is to remove the rational number case from the
definition of mapatom, but I wonder if that wouldn't break existing user
code, where mapatom(ex) is a pretty common base case for structural
recursion, and indeed with inflag=true, the code might not be prepared to
handle "/" at all, since it normally doesn't occur.  Would we then 'cheat'
and claim that the internal form of 2/3 is actually 2*3^-1 ???!!!

          -s

On Wed, Sep 26, 2012 at 2:17 PM, Christopher Sangwin <c.j.sangwin at bham.ac.uk
> wrote:

> Dear list,****
>
> ** **
>
> A strange error has surfaced, and I?m at a loss to explain why.****
>
> ** **
>
> It can be reproduced on****
>
> Maxima version: 5.27.0  Lisp: GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)
> ****
>
> ** **
>
> And also as the following.****
>
> ** **
>
> Maxima 5.28.0 http://maxima.sourceforge.net****
>
> using Lisp CLISP 2.49 (2010-07-07)****
>
> Distributed under the GNU Public License. See the file COPYING.****
>
> Dedicated to the memory of William Schelter.****
>
> The function bug_report() provides bug reporting information.****
>
> (%i1) map(f,1/a);****
>
>                                      f(1)****
>
> (%o1)                                ----****
>
>                                      f(a)****
>
> (%i2) map(f,1/2);****
>
>                         1****
>
> map: improper argument: -****
>
>                         2****
>
> -- an error. To debug this try: debugmode(true);****
>
> ** **
>
> But****
>
> ** **
>
> (%i3) atom(1/2);****
>
> (%o3)                                false****
>
> ** **
>
> I don?t mind checking that the second argument to map is not atomic, but I
> don?t understand this at all.  Can anyone help please?****
>
> ** **
>
> Chris****
>
> ** **
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>