knowledge-database (beta)

Current group: comp.lang.apl

Selective nesting

Selective nesting  
Ric
 Re: Selective nesting  
Graham Steer
 Re: Selective nesting  
Stefano Lanzavecchia
 Re: Selective nesting  
Ric
From:Ric
Subject:Selective nesting
Date:25 Nov 2004 05:40:57 -0800
Let's say I have the following vector of nested strings in APL+WIN

x{<-}'aaa' 'bbb' 'ccc' 'ccc' 'ddd'

I want to nest those that are the same eg.

..…---------------------.
|.…-..…-..…-------..…-.|
||aa||bb||.…-..…-.||dd||
|'--''--'||cc||cc||'--'|
| |'--''--'| |
| '¹-------' |
'¹---------------------'

One option is to use dyadic enclose to nest all of them

(x{iota}x){enclose}x

..…---------------------------.
|.…---..…---..…-------..…---.|
||.…-.||.…-.||.…-..…-.||.…-.||
|||aa||||bb||||cc||cc||||dd|||
||'--'||'--'||'--''--'||'--'||
|'¹---''¹---''¹-------''¹---'|
'¹---------------------------'

And then selectively disclose the ones with shape of one, but that's
got me stumped too! Any pointers?

Thanks.
From:Graham Steer
Subject:Re: Selective nesting
Date:Thu, 25 Nov 2004 16:53:04 -0000
Ric,

Not very elegant but you could simply replace rather than disclose the
unique elements after nesting them all

y <- (x{iota}x){enclose}x
then
xi <- x{iota}x
yi <- +\xi={iota}{rho}x
xi <- ((xi{not equal}1{rotate}xi){and}xi{not equal}¯1{rotate}xi)/xi
yi <- ((yi{not equal}1{rotate}yi){and}yi{not equal}¯1{rotate}yi)/yi
y[yi] <- x[xi]

"Ric" wrote in message
news:9355bc02.0411250540.472471ce@posting.google.com...
> Let's say I have the following vector of nested strings in APL+WIN
>
> x{<-}'aaa' 'bbb' 'ccc' 'ccc' 'ddd'
>
> I want to nest those that are the same eg.
>
> ..---------------------.
> |..-...-...-------...-.|
> ||aa||bb||..-...-.||dd||
> |'--''--'||cc||cc||'--'|
> | |'--''--'| |
> | '¹-------' |
> '¹---------------------'
>
> One option is to use dyadic enclose to nest all of them
>
> (x{iota}x){enclose}x
>
> ..---------------------------.
> |..---...---...-------...---.|
> ||..-.||..-.||..-...-.||..-.||
> |||aa||||bb||||cc||cc||||dd|||
> ||'--'||'--'||'--''--'||'--'||
> |'¹---''¹---''¹-------''¹---'|
> '¹---------------------------'
>
> And then selectively disclose the ones with shape of one, but that's
> got me stumped too! Any pointers?
>
> Thanks.
From:Stefano Lanzavecchia
Subject:Re: Selective nesting
Date:Thu, 25 Nov 2004 16:56:43 +0100
Given:

z<- (x iota x)enclose x

> And then selectively disclose the ones with shape of one, but that's
> got me stumped too! Any pointers?

Sorry... no APL2ASCII because I am too lazy :-)

Anyway:
y<-1=enlist rho each z
(y/z)<-first each y/z

Careful if y doesn't even contain a 1 or if x is empty... Fill elements will
play tricks on you...
--
WildHeart'2k4
From:Ric
Subject:Re: Selective nesting
Date:25 Nov 2004 12:26:35 -0800
"Stefano Lanzavecchia" wrote in message news:<30mdltF32o1heU1@uni-berlin.de>...
> Anyway:
> y<-1=enlist rho each z
> (y/z)<-first each y/z
>
> Careful if y doesn't even contain a 1 or if x is empty... Fill elements will
> play tricks on you...

Thanks Stefano,
seems pretty stable to empty x. My solution that I was using was as
follows:
foo{each}z
where foo was a function that tested for 1={rho} and did a disclose if
that was the case. Don't think it is as stable to empty x and is abit
ugly.
Ric
   

Copyright © 2006 knowledge-database   -   All rights reserved