• Re: How can I make Reduce run from right to left?

    From J-P. Rosen@21:1/5 to All on Tue Dec 10 18:57:45 2024
    Le 10/12/2024 à 18:20, Brian9000 a écrit :
    but the compiler won't accept "reverse" in the next-to-last line, even though you can use it in a normal loop. The other lines compile and run without any problems.ARM 2022/4.5.10(6/5):
    The iterated_element_association of a value_sequence shall not have a key_expression, nor shall it have a loop_parameter_specification that
    has the reserved word reverse.

    --
    J-P. Rosen
    Adalog
    2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
    https://www.adalog.fr https://www.adacontrol.fr

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From J-P. Rosen@21:1/5 to All on Tue Dec 10 18:54:27 2024
    Le 10/12/2024 à 18:20, Brian9000 a écrit :
    but the compiler won't accept "reverse" in the next-to-last line, even
    though you can use it in a normal loop.  The other lines compile and run without any problems.
    ARM 2022/4.5.10(6/5):
    The iterated_element_association of a value_sequence shall not have a key_expression, nor shall it have a loop_parameter_specification that
    has the reserved word reverse.

    --
    AEiC 2025 logo <https://www.ada-europe.org/conference2025>
    J-P. Rosen
    Adalog
    2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
    https://www.adalog.fr https://www.adacontrol.fr

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jeffrey R.Carter@21:1/5 to All on Tue Dec 10 22:04:02 2024
    On 2024-12-10 18:20, Brian9000 wrote:
     Ada.Text_IO.Put_Line (Real'Image ([ for i in reverse 0 .. data'Last -
    1 => data(i) ]'Reduce("-", data(data'Last))));

    Presumably you could do

    [for I in 0 .. Data'Last - 1 => Data (Data'Last - 1 - I)]'Reduce

    Or write a Reverse function

    Reverse (Data (0 .. Data'Last - 1) )'Reduce

    --
    Jeff Carter
    "An essential part of teaching Ada is not
    the technical details, but the message of
    software engineering."
    Jean-Pierre Rosen
    167

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