Linda mentioned this old thread very recently and I noticed a way to
tie together mijj contribution with the original question. In the
original question the example data specimen was as follows.

aa=. 2 7 $ 6;30;1;17;119;118;116;63;2;5;17;103;14;1

But mijj seemed to want to extend the case to a list of long integers
like follows using the verb s/he invented `concatIntegers  =.
,&'x'@,&.":`.

(5 $ 1234567890)

Using `each` there is a pretty concise way to deal with the original
problem that requires no transpose verb for example, as shown here.

   concatIntegers  =. ,&'x'@,&.":
   concatIntegers each/aa
┌───┬───┬──┬────┬──────┬─────┬────┐
│663│302│15│1717│119103│11814│1161│
└───┴───┴──┴────┴──────┴─────┴────┘

More flogging, though <grin>.




On Mon, Jul 18, 2011 at 5:50 PM, mijj <[email protected]> wrote:
> (Department of Flogging a Dead Horse)
>
> Given my prev exerience of improperly converting a long integer string
> to integer, it's prob worthwhile appending an 'x' to the string before
> [&.":] converts it back to integer number.
>
> i.e.
> (convert to string) (concat strings) (append 'x') (convert to integer)
>
> ,&'x'@,&.":/ (5 $ 1234567890)
> NB. 12345678901234567890123456789012345678901234567890
>
> i.e
> concatIntegers  =. ,&'x'@,&.":
> concatIntegers/ (5 $ 1234567890)
> NB. 12345678901234567890123456789012345678901234567890
>
> Dead subject, i know, but it was niggling me.
>
>
> On 2011-07-15 04:49, PackRat wrote:
>> I wish to append the digits of two numbers to form a new number:
>>    12  345  -->   12345
>>
>> I'm sure this is elementary, but I'm currently stumped.  Here's some
>> data (which in reality would have been read in from a CSV file and then
>> transposed):
>>
>> aa=. 2 7 $ 6;30;1;17;119;118;116;63;2;5;17;103;14;1
>>
>> +--+--+-+--+---+---+---+
>> |6 |30|1|17|119|118|116|
>> +--+--+-+--+---+---+---+
>> |63|2 |5|17|103|14 |1  |
>> +--+--+-+--+---+---+---+
>>
>> Then I pulled out the numeric data pairs, converted them to literals,
>> and appended them:
>>
>> b=. ( ": every 0{aa ) ,. ( ": every 1{aa )
>>
>> 6  63
>> 30 2
>> 1  5
>> 17 17
>> 119103
>> 11814
>> 1161
>>
>> Just for visual purposes here (NOT in J!), I substituted * for spaces,
>> to show what's happening:
>>
>> 6**63*
>> 30*2**
>> 1**5**
>> 17*17*
>> 119103
>> 11814*
>> 1161**
>>
>> However, what I want to end up with is this, no spaces, different
>> lengths:
>>
>> 663
>> 302
>> 15
>> 1717
>> 119103
>> 11814
>> 1161
>>
>> To attempt to do this, I did the following:
>>
>> spc=. ' ' E. every b
>>
>> 0 1 1 0 0 1
>> 0 0 1 0 1 1
>> 0 1 1 0 1 1
>> 0 0 1 0 0 1
>> 0 0 0 0 0 0
>> 0 0 0 0 0 1
>> 0 0 0 0 1 1
>>
>> keepmask=. (0 = spc)
>>
>> 1 0 0 1 1 0
>> 1 1 0 1 0 0
>> 1 0 0 1 0 0
>> 1 1 0 1 1 0
>> 1 1 1 1 1 1
>> 1 1 1 1 1 0
>> 1 1 1 1 0 0
>>
>> I thought that the following would accomplish what I wanted, but it
>> does NOT:
>>
>> nospc=. keepmask # each b
>>
>> +-+-+-+-+-+-+
>> |6| | |6|3| |
>> +-+-+-+-+-+-+
>> |3|0| |2| | |
>> +-+-+-+-+-+-+
>> |1| | |5| | |
>> +-+-+-+-+-+-+
>> |1|7| |1|7| |
>> +-+-+-+-+-+-+
>> |1|1|9|1|0|3|
>> +-+-+-+-+-+-+
>> |1|1|8|1|4| |
>> +-+-+-+-+-+-+
>> |1|1|6|1| | |
>> +-+-+-+-+-+-+
>>
>> Essentially, this puts me right back where I started, without
>> accomplishing anything.  I thought it would be a very straightforward
>> process to append the digits of two numbers--it's sort of the reverse
>> of what was discussed here recently.  The final step, of course, is to
>> convert the new literal back into a number (but that part's easy!).
>>
>> I appreciate any help with this--thanks in advance!
>>
>> Harvey
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm



-- 
(B=) <-----my sig
Brian Schott
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to