• colon vs semicolon in loops

    From jfh@21:1/5 to All on Sun Jun 17 18:36:53 2018
    How does one get Maple to display some but not all of the results in a loop? The Maple output below displays everything done in a loop ending "end if;" and nothing done in a loop ending "end if:" but one of the two commands inside each loop ends with ":"
    and the other with ";". I know the output is what my program asked for but it's not what I had hoped for.

    |\^/| Maple 2017 (X86 64 LINUX)
    ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2017
    \ MAPLE / All rights reserved. Maple is a trademark of
    <____ ____> Waterloo Maple Inc.
    | Type ? for help.
    # test : vs ; in loops

    for n from 1 to 2 do
    n:
    n^2;
    end do:

    for n from 1 to 2 do
    n:
    n^3;
    end do;
    1

    1

    2

    8

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nasser M. Abbasi@21:1/5 to jfh on Mon Jun 18 06:55:30 2018
    On 6/17/2018 8:36 PM, jfh wrote:
    How does one get Maple to display some but not all of the results in a loop? The Maple output below displays everything done in a loop ending "end if;" and nothing done in a loop ending "end if:" but one of the two commands inside each loop ends with ":
    " and the other with ";". I know the output is what my program asked for but it's not what I had hoped for.

    |\^/| Maple 2017 (X86 64 LINUX)
    ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2017
    \ MAPLE / All rights reserved. Maple is a trademark of
    <____ ____> Waterloo Maple Inc.
    | Type ? for help.
    # test : vs ; in loops

    for n from 1 to 2 do
    n:
    n^2;
    end do:

    for n from 1 to 2 do
    n:
    n^3;
    end do;
    1

    1

    2

    8


    as far as I know, it is not possible to do what you want.

    I'd use a ":" for the "end do:" and then use ":" inside
    the loop for the ones you do not want echoed to screen,
    and for the ones you want to see, use an explicit print() on them.

    for n from 1 to 2 do
    n:
    print(n^3);
    od:

    1
    8

    --Nasser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jfh@21:1/5 to Nasser M. Abbasi on Mon Jun 18 16:27:24 2018
    On Monday, June 18, 2018 at 11:55:31 PM UTC+12, Nasser M. Abbasi wrote:
    On 6/17/2018 8:36 PM, jfh wrote:
    How does one get Maple to display some but not all of the results in a loop? The Maple output below displays everything done in a loop ending "end if;" and nothing done in a loop ending "end if:" but one of the two commands inside each loop ends with
    ":" and the other with ";". I know the output is what my program asked for but it's not what I had hoped for.

    |\^/| Maple 2017 (X86 64 LINUX)
    ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2017
    \ MAPLE / All rights reserved. Maple is a trademark of
    <____ ____> Waterloo Maple Inc.
    | Type ? for help.
    # test : vs ; in loops

    for n from 1 to 2 do
    n:
    n^2;
    end do:

    for n from 1 to 2 do
    n:
    n^3;
    end do;
    1

    1

    2

    8


    as far as I know, it is not possible to do what you want.

    I'd use a ":" for the "end do:" and then use ":" inside
    the loop for the ones you do not want echoed to screen,
    and for the ones you want to see, use an explicit print() on them.

    for n from 1 to 2 do
    n:
    print(n^3);
    od:

    1
    8

    --Nasser

    Thank you. I need only add that even saying "print(n^3):" to end the command with a colon would still get the value of n^3 printed. Replacing print with lprint, or printf with a suitable format, would also overrule the colon.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)