Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

qsortf one function that use one function for compare 2 elements

68 views
Skip to first unread message

Rosario19

unread,
Nov 26, 2023, 2:42:34 AM11/26/23
to


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} )?

Sudleyplace

unread,
Nov 26, 2023, 9:16:44 PM11/26/23
to
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.

Rosario19

unread,
Nov 27, 2023, 11:52:51 PM11/27/23
to
On Sun, 26 Nov 2023 18:16:42 -0800 (PST), Sudleyplace
<bsm...@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?

Bob Smith

unread,
Nov 28, 2023, 8:14:23 PM11/28/23
to
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 -- bsm...@sudleydeplacespam.com
http://www.sudleyplace.com - http://www.nars2000.org

To reply to me directly, delete "despam".

Rosario19

unread,
Nov 29, 2023, 11:32:19 AM11/29/23
to
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
>> <bsm...@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
0 new messages