• qsortf one function that use one function for compare 2 elements

    From Rosario19@21:1/5 to All on Sun Nov 26 08:41:50 2023
    In the page of internet of "rosetta code", there is one APL function
    qsort
    but here in Nars2000 there is some problem

    qsort {leftarrow} {leftbrace}1{rightcaretunderbar}r{leftarrow}{notequalunderbar}{omega}:{omega}{diamond}p{leftarrow}{omega}[?r]{diamond}({del}({omega}<p)/{omega}),(({omega}=p)/{omega}),({del}({omega}>p)/{omega}){rightbrace}

    qsort 45 7 88 55 4 6 89
    LIMIT ERROR

    My workaround is not write ?r but use floor(r/2) instead. Than added
    some code for use one extern compare function for 2 elements

    qsortf{leftarrow}{leftbrace}1{rightcaretunderbar}r{leftarrow}{notequalunderbar}{omega}:{omega}{diamond}p{leftarrow}{omega}{rightshoe}{dieresistilde}{downstile}r{colonbar}2{diamond}k{leftarrow}{alpha}{alpha}{leftbrace}{omega}{alpha}{alpha}p{rightbrace}{
    dieresis}{omega}{diamond}({alpha}{alpha}{del}{del}(0<k)/{omega}),((0=k)/{omega}),({alpha}{alpha}{del}{del}(0>k)/{omega}){rightbrace}

    This order using function -
    -qsortf 45 7 88 55 4 6 89
    +7-----------------+
    89 88 55 45 7 6 4
    +~-----------------+
    this use the function -{dieresistilde} (im not so sure {dieresistilde}
    is the right traslation)
    -{dieresistilde}qsortf 45 7 88 55 4 6 89
    +7-----------------+
    4 6 7 45 55 88 89
    +~-----------------+
    this order using the first element of array element
    {?[1]<?[1]:1??[1]=?[1]:0?1} qsortf (45 2) (7 9) (88 1) (55 3)
    (4 5) (6 11) (89 8)
    +7----------------------------------------------------+
    +2----+ +2----+ +2----+ +2----+ +2---+ +2----+ +2---+
    89 8 88 1 55 3 45 2 7 9 6 11 4 5
    +~----+ +~----+ +~----+ +~----+ +~---+ +~----+ +~---+2 +?----------------------------------------------------+

    someone note something wrong? is there some error (because i'm not
    familiar in use function {alpha}{alpha} or {del}{del} )?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sudleyplace@21:1/5 to All on Sun Nov 26 18:16:42 2023
    On Sunday, November 26, 2023 at 2:42:34 AM UTC-5, Rosario19 wrote:
    In the page of internet of "rosetta code", there is one APL function
    qsort
    but here in Nars2000 there is some problem

    qsort {leftarrow} {leftbrace}1{rightcaretunderbar}r{leftarrow}{notequalunderbar}{omega}:{omega}{diamond}p{leftarrow}{omega}[?r]{diamond}({del}({omega}<p)/{omega}),(({omega}=p)/{omega}),({del}({omega}>p)/{omega}){rightbrace}

    qsort 45 7 88 55 4 6 89
    LIMIT ERROR

    So sorry, you found a bug in NARS2000 which I've fixed in the beta version: https://www.nars2000.org/download/binaries/beta/. Please try running your qsort function again on the beta version.

    My workaround is not write ?r but use floor(r/2) instead. Than added
    some code for use one extern compare function for 2 elements

    qsortf{leftarrow}{leftbrace}1{rightcaretunderbar}r{leftarrow}{notequalunderbar}{omega}:{omega}{diamond}p{leftarrow}{omega}{rightshoe}{dieresistilde}{downstile}r{colonbar}2{diamond}k{leftarrow}{alpha}{alpha}{leftbrace}{omega}{alpha}{alpha}p{rightbrace}{
    dieresis}{omega}{diamond}({alpha}{alpha}{del}{del}(0<k)/{omega}),((0=k)/{omega}),({alpha}{alpha}{del}{del}(0>k)/{omega}){rightbrace}

    This order using function -
    -qsortf 45 7 88 55 4 6 89
    +7-----------------+
    Ś 89 88 55 45 7 6 4Ś
    +~-----------------+
    this use the function -{dieresistilde} (im not so sure {dieresistilde}
    is the right traslation)
    -{dieresistilde}qsortf 45 7 88 55 4 6 89
    +7-----------------+
    Ś 4 6 7 45 55 88 89Ś
    +~-----------------+
    this order using the first element of array element {?[1]<?[1]:Ż1??[1]=?[1]:0?1} qsortf (45 2) (7 9) (88 1) (55 3)
    (4 5) (6 11) (89 8)
    +7----------------------------------------------------+
    Ś+2----+ +2----+ +2----+ +2----+ +2---+ +2----+ +2---+Ś
    ŚŚ 89 8Ś Ś 88 1Ś Ś 55 3Ś Ś 45 2Ś Ś 7 9Ś Ś 6 11Ś Ś 4 5ŚŚ Ś+~----+ +~----+ +~----+ +~----+ +~---+ +~----+ +~---+2 +?----------------------------------------------------+

    someone note something wrong? is there some error (because i'm not
    familiar in use function {alpha}{alpha} or {del}{del} )?

    I'm not sure what you are expecting. Does the output look incorrect?

    Also, it would be *so much easier* for me to help you if you were to use actual APL characters in your messages. To do this, copy the APL code from your NARS2000 session and paste it into your message, along with the boxed output. There may be other
    settings to change such as use an APL font, and UTF-8 encoding, but let's try just copying APL code first. Please, please do this.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rosario19@21:1/5 to All on Tue Nov 28 05:52:08 2023
    On Sun, 26 Nov 2023 18:16:42 -0800 (PST), Sudleyplace
    <bsmith@sudleyplace.com> wrote:
    if there is one wuestion i would ask? yes one general apl question
    why enter as input
    1 1
    is one array of 2 elements
    the same of
    (1 1)
    ?

    Why (1 1) is not the array 1 1, enclosed?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bob Smith@21:1/5 to All on Tue Nov 28 20:14:14 2023
    On 11/27/2023 11:52 PM, Rosario19 wrote:
    On Sun, 26 Nov 2023 18:16:42 -0800 (PST), Sudleyplace <bsmith@sudleyplace.com> wrote:
    if there is one wuestion i would ask? yes one general apl question
    why enter as input
    1 1
    is one array of 2 elements
    the same of
    (1 1)
    ?

    Why (1 1) is not the array 1 1, enclosed?

    The best description I've found to answer this question is from the APL2 Language Reference Manual (apl2lrm.pdf, p.37) which says

    "In expressions of arrays, parentheses that do not separate and group
    are redundant".

    That is, in a←(1 1) the parens group but do not separate, and so they
    are redundant, meaning that a←(1 1) is equivalent to a←1 1.

    In a←(1 1) (2 2) as in a←(1 1) 2 2 the parens both group and separate,
    and so they are not redundant, meaning that no set of parens may be
    removed without changing the meaning of that expression.

    In a←(1) (2) as in a←(1) 2 the parens separate but do not group, so they are all redundant.

    --
    _________________________________________
    Bob Smith -- bsmith@sudleydeplacespam.com
    http://www.sudleyplace.com - http://www.nars2000.org

    To reply to me directly, delete "despam".

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rosario19@21:1/5 to Bob Smith on Wed Nov 29 17:31:39 2023
    On Tue, 28 Nov 2023 20:14:14 -0500, Bob Smith wrote:

    On 11/27/2023 11:52 PM, Rosario19 wrote:
    On Sun, 26 Nov 2023 18:16:42 -0800 (PST), Sudleyplace
    <bsmith@sudleyplace.com> wrote:
    if there is one wuestion i would ask? yes one general apl question
    why enter as input
    1 1
    is one array of 2 elements
    the same of
    (1 1)
    ?

    Why (1 1) is not the array 1 1, enclosed?

    The best description I've found to answer this question is from the APL2 >Language Reference Manual (apl2lrm.pdf, p.37) which says

    "In expressions of arrays, parentheses that do not separate and group
    are redundant".

    That is, in a?(1 1) the parens group but do not separate, and so they
    are redundant, meaning that a?(1 1) is equivalent to a?1 1.

    In a?(1 1) (2 2) as in a?(1 1) 2 2 the parens both group and separate,
    and so they are not redundant, meaning that no set of parens may be
    removed without changing the meaning of that expression.

    In a?(1) (2) as in a?(1) 2 the parens separate but do not group, so they
    are all redundant.

    ok thank you

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