Are you the publisher? Claim or contact us about this channel


Embed this content in your HTML

Search

Report adult content:

click to rate:

Account: (login)

More Channels


Channel Catalog


Articles on this Page

(showing articles 1 to 2 of 2)
(showing articles 1 to 2 of 2)

Channel Description:

The most recent questions and posts on MaplePrimes tagged with goto
    0 0
  • 07/09/08--16:14: implementing switch/case?
  • Is there a switch/case statement in Maple?  So that instead of:

     

    if (a = a1) then

       b1

    elif (a = a2) then

       b2

    elif (a = a3) then

      b3

    end if

     

    Something like:

     

    switch (a) {

    case: a1 {b1}

    case: a2 {b2}

    case: a3 {b3}

    }

     

    ???

     

    I'm potentially going to have a long list of elif's and might need  more efficient way of doing it.


    0 0

    Hi everybody,

    I got an error message, when i try to profile code with a goto statement inside.
    Here is my minimal-example in Maple18. Is there a known conflict or what's wrong?

    f := proc(x)
        if x < 0 then goto(POS): end if;
        return "A";
        
        POS:
        return "B";
    end proc:

    f(-3);
                                  "B"
    f(3);
                                  "A"

    CodeTools[Profiling]:-Profile(f);
    f(-3);
    CodeTools[Profiling]:-PrintProfiles(f);
    CodeTools[Profiling]:-UnProfile(f);

    Error, (in f) goto to an undefined or unreachable label
    f
    f := proc(x)
         |Calls Seconds  Words|
    PROC |    1   0.000      3|
          1 |    1   0.000      3| if x < 0 then
          2 |    1   0.000      0|   goto(POS)
                                   end if;
          3 |    0   0.000      0| return "A";
          4 |    0   0.000      0| POS;
          5 |    0   0.000      0| return "B"
    end proc