(<'=:') splitstring each ('a=:b';'c=:dz')
+-----+------+
|+-+-+|+-+--+|
||a|b|||c|dz||
|+-+-+|+-+--+|
+-----+------+
'=:' splitstring L:0 ('a=:b';'c=:dz')
+-----+------+
|+-+-+|+-+--+|
||a|b|||c|dz||
|+-+-+|+-+--+|
+-----+------+
R.E. Boss
(Add your info to http://www.jsoftware.com/jwiki/Community/Demographics )
> -----Original Message-----
> From: [email protected] [mailto:programming-
> [email protected]] On Behalf Of Joe Bogner
> Sent: vrijdag 17 januari 2014 16:29
> To: [email protected]
> Subject: [Jprogramming] Adverb each rank
>
> Starting a new thread from
> http://jsoftware.com/pipermail/programming/2014-January/034594.html
> for better future searching and more relevant subject
>
> On Fri, Jan 17, 2014 at 5:52 AM, Raul Miller <[email protected]> wrote
> > Have you seen the wikipedia entry on rank?
> > http://en.wikipedia.org/wiki/Rank_(J_programming_language)
>
> Yes, that's been helpful in the past. Thank you for writing and
> sharing it. It would be useful to add language for infinite rank,
> which seems to be what I'm tripping up on.
>
> '=:' splitstring each ('a=:b';'c=:dz')
> ┌──────┬───────┐
> │┌─┬──┐│┌──┬──┐│
> ││a│:b│││c=│dz││
> │└─┴──┘│└──┴──┘│
> └──────┴───────┘
>
> I have a solution that seems more appropriate, to bond the left
> argument to splitstring to create a monad
>
> '=:'&splitstring each ('a=:b';'c=:dz')
> ┌─────┬──────┐
> │┌─┬─┐│┌─┬──┐│
> ││a│b│││c│dz││
> │└─┴─┘│└─┴──┘│
> └─────┴──────┘
>
> Going back to the faulty one, I'm seeking to understand why it does that:
>
> splitstring has infinite rank
>
> splitstring b. 0
> _ _ _
>
> Something is triggering it to operate like this:
>
> for(i = 0; i<leftLength;i++) {
> left[i] splitstring right[i]
> }
>
> '=' splitstring 'a=:b'
> ':' splitstring 'c=:dz'
>
> This can be demonstrated by doing this:
>
> '=:z' splitstring each ('a=:b';'f=:m')
> |length error
> | '=:z' splitstring each('a=:b';'f=:m')
>
> Which fails because the left shape is greater than the right shape.
>
> If I try to look at the rank of each, that doesn't work:
>
> each b. 0
> |syntax error
> | each b.0
>
> each is an adverb created with the &. conjunction
>
> The dictionary[1] says:
>
> "The verb u &.v is equivalent to the composition u & v except that the
> verb obverse to v is applied to the result for each cell. That is
> (subject to the monadic rank of v)"
>
> This looks like it came up at a NYCJUG[2]
>
> "It doesn’t work – why? Based on the shape of the result, we might
> suspect a problem with rank. Unfortunately, we can’t specify the rank
> of an adverb:"
>
> If I understand the dictionary correctly, it will use the rank of the
> verb, which for each is >. > has a rank 0 0 0.
>
> > b. 0
> 0 0 0
>
> As a more simple example, it looks like it's doing something like this:
>
> '=:' ,"0 0 1 'bbcc'
> =bbcc
> :bbcc
>
> Rank for the monad case (−y is an example of using − as a monad)
> Rank for the left argument for the dyad case (x−y is an example of
> using − as a dyad)
> Rank for the right argument for the dyad case
>
> Can anyone shed some light on why '=:' splitstring each
> ('a=:b';'c=:dz') is applying its left argument iteratively to the
> right argument? Am I on the right path with this analysis?
>
>
> [1] - http://www.jsoftware.com/help/dictionary/d631.htm
> [2] - http://www.jsoftware.com/jwiki/NYCJUG/2013-01-08
> [3] - http://en.wikipedia.org/wiki/Rank_(J_programming_language)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm