Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!watserv1!71477.330@compuserve.com
From: Randy A MacDonald <71477.330@CompuServe.COM>
Subject: Re: help with a j "split" function
Message-ID: <930224055036_71477.330_DHG43-1@CompuServe.COM>
Sender: hesse@watserv1.uwaterloo.ca
Organization: University of Waterloo
Date: Wed, 24 Feb 1993 05:50:37 GMT

NB.   Emmet McLean writes:

NB. NB. Alan Baljeu writes:
NB. NB.
NB. NB. >I'm trying to construct a function that will work like this:
NB. NB. >
NB. NB. >   0 1 2 1 0 0 1 split 1 2 3 4 5 6 7
NB. NB. >+-------+-------+---+
NB. NB. >| 1 5 6 | 2 4 7 | 3 |
NB. NB. >+-------+-------+---+
NB. NB. >
NB. NB. >By the way, I'll probably use the function like:
NB. NB. >   fivesplit =. (5: > right) split right
NB. NB. >   fivesplit 2 4 7 3 76
NB. NB. >+-------+------+
NB. NB. >| 2 4 3 | 7 76 |
NB. NB. >+-------+------+
NB. NB.
NB. NB. 0!:2 This, it should be what you want.

NB.   right =. ]
NB.   split =. </.
NB.   fivesplit =. (5: > right) split right
NB.   0 1 1 2 split 3 4 5 6
NB.   0 1 2 1 0 0 1 split 1 2 3 4 5 6 7
NB.   fivesplit 2 4 7 3 76

    <'Emmett'

NB. Alan Baljeu ALSO writes:

NB.        1 1 0 1 0 split 2 5 6 1 2
NB. +-----+-------+
NB. | 6 2 | 2 5 1 |
NB. +-----+-------+
NB. I'll be satisfied if only the second example is accomplished.


    1 1 0 1 0 split 2 5 6 1 2 NB.  OOPS, not quite!
+-------+-----+
| 2 5 1 | 6 2 |
+-------+-----+

    NB.  There is an assumed ordering of the result. MAy or may not be 
    NB.  important, but note that:

    fivesplit 2 4 7 3 76
+-------+------+
| 2 4 3 | 7 76 |
+-------+------+

    fivesplit 76 3 7 4 2
+------+-------+
| 7 76 | 2 4 3 |
+------+-------+

    NB.  If you assume the smaller ones are in the first item, WRONG!
    NB.  So i try doing the split, and sorting by the nub of x.

    spl =. '' : '(/:~.x.)(x. </. y.)'

    1 1 0 1 0 spl 2 5 6 1 2 NB. now we're cookin' wit' gas.
+==-----+-----+
| 2 5 1 | 6 2 |
+-------+-----+

    NB.  I thought the Key conjunction was enough too, but sorting makes
    NB.  it so...

NB. |\/|
NB. |\\| Randy MacDonald            JCPWDP




