This would preclude the possibility of having adjacent
groups at the same depth. e.g.

   2 3 4,:1 1 2

But perhaps you don't want this possibility.



----- Original Message -----
From: "R.E. Boss" <[email protected]>
Date: Thursday, June 4, 2009 5:20
Subject: Re: [Jprogramming] leveled as indicated
To: 'Programming forum' <[email protected]>

> Perhaps the left argument could better be given as #~/x as in 
> 
>    #~/ 1 2 3 2 3 1,:2 1 3 2 1 3
> 1 1 2 3 3 3 2 2 3 1 1 1
> 
> where the value gives the level depth and the value ranges
> determine the ranges in y .
> Then a solution is
> 
> foo1=: 4 : '<@]^:({...@[)&>/"1 |:(<1 ,~ (}: ~: }.)x) <;.2 
> &> x ; y'
> 
> 1 1 2 3 3 3 2 2 3 1 1 1 foo1 i.12
> +---+---+---------+-----+-----+-------+
> |0 1|+-+|+-------+|+---+|+---+|9 10 11|
> |   ||2|||+-----+|||6 7|||+-
> +||       |
> |   |+-+|||3 4 5|||+---
> +|||8|||       |
> |   |   ||+-----+||     
> ||+-+||       |
> |   |   |+-------+|     
> |+---+|       |
> +---+---+---------+-----+-----+-------+
> 
> 
> R.E. Boss
> 
> 
> > -----Oorspronkelijk bericht-----
> > Van: [email protected] [mailto:programming-
> > [email protected]] Namens R.E. Boss
> > Verzonden: donderdag 4 juni 2009 8:49
> > Aan: 'Programming forum'
> > Onderwerp: Re: [Jprogramming] leveled as indicated
> > 
> > My solution was
> > 
> > foo=: 4 : 0
> > 'x0 x1'=. x
> > z=. (<"0 x0) ,. (x1 # i.#x1)</.y
> > (<@]^:[&>/)"1 z
> > )
> > 
> > It contains parts of both your and Hui's solution.
> > Thanks.
> > 
> > 
> > R.E. Boss
> > 
> > 
> > > -----Oorspronkelijk bericht-----
> > > Van: [email protected] [mailto:programming-
> > > [email protected]] Namens Raul Miller
> > > Verzonden: woensdag 3 juni 2009 21:42
> > > Aan: Programming forum
> > > Onderwerp: Re: [Jprogramming] leveled as indicated
> > >
> > > foo=:4 :0
> > >   assert. 4 = (3!:0) 
> x         NB. x is integer
> > >   assert. 2 = # 
> x              NB. x has 2 items
> > >   assert. 2 = #$ x     NB. x 
> has rank 2
> > >   assert. (# y) = +/{: x
> > >   assert. 0 < <./{. 
> x          NB. {.x 
> is positive
> > >   'd l'=.x
> > >   d <@]^:[&> (; l {.&.> 1) <;.1 y
> > > )
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to