foo =: (~: 1&|.) <^:{.;.2 ] 

This is a fork
left verb is a hook defining the end of each sequence,
middle verb  <^:{.;.2  cuts each sequence and applies boxing multiple number of 
times, where the number of times is the first number in the sequence.

Ian






Message: 3
Date: Thu, 24 Nov 2011 15:27:19 +0100
From: "R.E. Boss" <[email protected]>
Subject: [Jprogramming] multiple boxing
To: "Programming forum" <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain;       charset="us-ascii"

Given an array of positive integers A starting with 1 and such that  2 > >./
2 -~/\ A  

 (a next atom in A is at most 1 larger than the preceding one).

 

Now I want the items to be boxed according to this example

 

    foo  1 1 2 2 3 3 4 2 3 4 4 1 2 2 2 1

+---+---------------------------+-+-------+-+

|1 1|+---+---------+-+---------+|1|+-----+|1|

|   ||2 2|+---+---+|2|+-+-----+|| ||2 2 2|| |

|   ||   ||3 3|+-+|| ||3|+---+||| |+-----+| |

|   ||   ||   ||4||| || ||4 4|||| |       | |

|   ||   ||   |+-+|| || |+---+||| |       | |

|   ||   |+---+---+| |+-+-----+|| |       | |

|   |+---+---------+-+---------+| |       | |

+---+---------------------------+-+-------+-+

 
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
This email is intended for the addressee(s) named and may contain confidential 
and/or privileged information. 
If you are not the intended recipient, please notify the sender and then delete 
it immediately.
Any views expressed in this email are those of the individual sender except 
where the sender expressly and with authority states them to be the views of 
the Office of Environment and Heritage, NSW Department of Premier and Cabinet.

PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS EMAIL

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to