[Jprogramming] multiple boxing (R.E. Boss)

Shannon Ian Ian.Shannon at environment.nsw.gov.au
Fri Nov 25 04:25:12 HKT 2011


 
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" <r.e.boss at planet.nl>
Subject: [Jprogramming] multiple boxing
To: "Programming forum" <programming at jsoftware.com>
Message-ID: <002101ccaab5$2c90a060$85b1e120$@planet.nl>
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



More information about the Programming mailing list