(;i{.&.>1) <;.1 az 
┌───┬──┬─────┬────────┬─────┬───┐
│abc│de│fghij│klmnopqr│stuvw│xyz│
└───┴──┴─────┴────────┴─────┴───┘
   ]c=:i{.&.>1
┌─────┬───┬─────────┬───────────────┬─
────────┬─────┐
│1 0 0│1 0│1 0 0 0 0│1 0 0 0 0 0 0 0│1 0 0 0 0│1 0 0│
└─────┴───┴─────────┴───────────────┴─
────────┴─────┘
   NB. x u&.v y ↔ vi (v x) u except that the verb obverse to v is applied
to the result for each cell. 
   
   d=:<"0(>i){.>1
   
   d-:c
0
(;i{.&.>1) <;.1 az 
┌───┬──┬─────┬────────┬─────┬───┐
│abc│de│fghij│klmnopqr│stuvw│xyz│
└───┴──┴─────┴────────┴─────┴───┘
   ]c=:i{.&.>1
┌─────┬───┬─────────┬───────────────┬─
────────┬─────┐
│1 0 0│1 0│1 0 0 0 0│1 0 0 0 0 0 0 0│1 0 0 0 0│1 0 0│
└─────┴───┴─────────┴───────────────┴─
────────┴─────┘
   NB. x u&.v y ↔ vi (v x) u except that the verb obverse to v is applied
to the result for each cell. 
   
   d=:<"0(>i){.>1
   d-:c
0
   d=:<"0(>"0 i){.>1
   d-:c
0

How can you write  d  so  d-:c .

Linda
 
-----Original Message-----
From: [email protected] [mailto:programming-
[email protected]] On Behalf Of Roger Hui
Sent: Tuesday, October 09, 2012 10:37 AM
To: [email protected]
Subject: Re: [Jprogramming] Partitioning a string into unequal-length parts

1. (;i{.&.>1) <;.1 az  (various ways of generating left argument; also use
<;._2 depending on left argument).
2. b <;._2 az



On Tue, Oct 9, 2012 at 7:32 AM, Ian Clark <[email protected]> wrote:

> 1. Suppose:
>    az=: 'abcdefghijklmnopqrstuvwxyz'
>    i=: 3 2 5 8 5 3      NB. -(for example)
>
> How best can I partition az into parts pp where (n{pp) has length (n{i) ?
> viz.
>    pp -:  'abc';'de';'fghij';'klmnopqr';'stuvw';'xyz'
>
> 2. Suppose instead of (i) I have a boolean (b) marking where to cut az ...
>    b =: 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 (c/f 
> dyadic {enclose} in APL+)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to