Wolfie7873

229 Reputation

6 Badges

18 years, 99 days

MaplePrimes Activity


These are answers submitted by Wolfie7873

I think I've got it now actually, subsop was the way to go, i just wasn't properly accounting for the various datatypes the function might encounter.

Yes, Alec, the idea is to improve comparison of RealRange(s).  For example, I want to easily compare the following:

a := RealRange(2,5)

b := RealRange(2,Open(5)) union {5}

c := (RealRange(1,Open(5)) union RealRange(5,10)) intersect RealRange(2,5)

and know whether they're equivalent.  So that compare(a,b) would yield true as would the other combinations.  I've got it working now, though.  Thanks to everyone for their help.

um yeah, no.  That's not what I mean.  The function I'm describing might take any number and combination of a few datatypes, so this isn't overloading, its typechecking, really.  But, I need to not destroy the function that comes to me.  For example:

 

Or(RealRange(1,5),{6})

 

I want to transform that into

 

Or(x::RealRange(1,5),x=6)

 

subsop does 'kinda' what I'm trying to do, but seems to not actually change anything:

> g := proc(z)
> local i;
> for i from 1 to nops(z) do
>    if (type(op(i,z),function)) then
>       z := subsop( i = x::op(i,z), z)
>    elif (type(op(i,z),set)) then
>       z := subsop( i = map(u->x=u,op(i,z))[], z)
>
>    end if;
> end do;
> return z;
> end proc:
 

> g(Or(RealRange(1,5),{6}));

Doesn't behave as expected.... at least not to what I expect.

 

In case anyone's interested, here's sort of the key to what I got working:

 

subs(`union`=Or,`intersect`=And,z);
z -> if (hasfun(z,`Or`) or hasfun(z,`And`)) then map(u->x::u,z) else x::z end if

 

That way the scoping is transparent to whether the interval is compound or not.  Then i do as you suggested by converting first to a relation, and then to a simplified piecewise function.

 

Thanks for the help.

I don't understand this part:

map(u->x::u,%);

Especially when I try to execute it on RealRange(2,6). Remember the goal is to manipulate the objects so that they end up the same.  How come map(u->x::u,RealRange(2,6)) returns unevaluated?

I figured as much about object types and such in Maple.  I'm not that confused by Maple's behavior, but I'm still ignorant of a solution to my problem.  Alec, you suggest programming a solution, but what details can you provide about the actual Maple object, RealRange that would assist in such an endeavor?

Thanks, Alec, but defining things in different terms changes the problem and doesn't solve mine.  I have to deal with ranges or intervals.  And, jakubi, your solution fails in the test case below...

 

R1 := RealRange(1,5);
                        R1 := RealRange(1, 5)

> R2 := RealRange(1,3) union RealRange(2,5);

            R2 := RealRange(1, 3)  union  RealRange(2, 5)

> is(R1 in R2);

                                 true

> is(R2 in R1);

                                 FAIL

Why doesn't Maple see R1 and R2 as equivalent objects?  How do I get Maple to see R1 and R2 as equivalent objects? 

Does the command work in Classic and Command Line 12 the same way as Standard 12?

Page 1 of 1