Here is a data array STEMPLOT which must include the data in the array.

STEMPLOT=: 0 : 
D=:/:~ (>:?15)+?10#120
D=:/:~16 48 60 69 95 101 108 108 117 130 
SL=:'S L'=:|:0 10#:D                               NB. stem and leaf ists
DD=:(<./S)+i.>:(>./S)-<./S                         NB. data domain  
SWL=:(":,.~.S),.'|'                                NB. stems with leaf
SNL=:(":,.(-.DD e.S) # DD),.'|'                    NB. stems without leaf
SD=:|."1(|."1 SWL),|."1 SNL                        NB. stem domain
LSP=:S ":/. L                                      NB. leaf stemplot
ALL=:SD,.LSP,((0{$SNL),1{$SL)$' '                  NB. stemplot  
GOOD=:((( ".}:"1 SD )-<./DD)i.i.$DD){"2 ALL       NB. good stemplot
   
   
   GOOD 
 1|6         
 2|          
 3|          
 4|8         
 5|          
 6|0 9       
 7|          
 8|          
 9|5         
10|1 8 8     
11|7         
12|          
13|0         
   
   D 
16 48 60 69 95 101 108 108 117 130
   
   
Or you can define a verb stemplot, which is in this case monadic.   
   
   stemplot=: 3 : 0
D=:/:~y 
SL=:'S L'=:|:0 10#:D                             NB. stem and leaf
DD=:(<./S)+i.>:(>./S)-<./S                       NB. data domain  
SWL=:(":,.~.S),.'|'                              NB. stem with leaf
SNL=:(":,.(-.DD e.S) # DD),.'|'                  NB. stem without leaf
SD=:|."1(|."1 SWL),|."1 SNL                      NB. stem domain
LSP=:S ":/. L                                    NB. leaf stemplot
ALL=:SD,.LSP,((0{$SNL),1{$SL)$' '                NB. stemplot  
]GOOD=:((( ".}:"1 SD )-<./DD)i.i.$DD){"2 ALL     NB.  good stemplot\)
)
      
   stemplot ?20$80
0|1 8                 
1|                    
2|0 2 3 5 6 9 9       
3|                    
4|0 0                 
5|4 5 7               
6|4 4 6 9             
7|0 7                 
   
stemplot 3 32 43 4 45 6 33
0|3 4 6  
1|       
2|       
3|2 3    
4|3 5    
   
   D
33 43 3 4 6 32 45

Linda
      

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Sunday, May 18, 2014 4:10 AM
To: [email protected]
Subject: Re: [Jprogramming] Stemplot

Now there are no defined verbs.

D=:/:~115 77 77 114 108 116 77
D=:/:~ (>:?15)+?10#120 
        
SL=:(S=:0{"2|:0 10#:D) ": /. L=:1{"2 |:0 10#:D     NB. stem and leaf
DD=:(<./S)+i.>:(>./S)-<./S                         NB. data domain  
SWL=:(":,.~.S),.'|'                                NB. stem with leaf
SNL=:(":,.(-.DD e.S) # DD),.'|'                    NB. stem without leaf
SD=:|."1(|."1 SWL),|."1 SNL                        NB. stem domain
LSP=:S ":/. L                                      NB. leaf stemplot
ALL=:SD,.LSP,((0{$SNL),1{$SL)$' '                 NB. stemplot  

]GOOD=:((( ".}:"1 SD )-<./DD)i.i.$DD){"2 ALL       NB. good stemplot

D

Here's the display.

]GOOD=:((( ".}:"1 SD )-<./DD)i.i.$DD){"2 ALL       NB. good stemplot
0|7  
1|1  
2|   
3|0 7
4|1 3
5|   
6|8  
7|1  
8|7  
9|1  
   
   D
7 11 30 37 41 43 68 71 87 91
   
   
Linda



-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Sunday, May 18, 2014 1:39 AM
To: [email protected]
Subject: Re: [Jprogramming] Stemplot

Actually this is all about data.  Here's another simplification.

D=:/:~115 77 77 114 108 116 77
D=:/:~ (>:?15)+?10#120 

SL=:(S=:0{"2|:0 10#:D) ": /. L=:1{"2 |:0 10#:D     NB. stem and leaf
do=: 13 :'(<./y)+i.>:(>./y)-<./y'                  NB. domain  
SWL=:(":,.~.S),.'|'                                NB. stem with leaf
SNL=:(":,.(-.(do S) e.S) # do S),.'|'              NB. stem without leaf
SD=:|."1(|."1 SWL),|."1 SNL                        NB. stem domain
LSP=:S ":/. L                                      NB. leaf stemplot
ALL=:SD,.LSP,((0{$SNL),1{$SL)$' '                  NB. stemplot  

]GOOD=:(((".0 1{"1 ALL)-<./do S)i.i.$do S){"2 ALL  NB. good stemplot

D

Here's a sample display:

]GOOD=:(((".0 1{"1 ALL)-<./do S)i.i.$do S){"2 ALL  NB. good stemplot
 0|7  
 1|5  
 2|   
 3|   
 4|   
 5|   
 6|   
 7|0 0
 8|2 4
 9|3  
10|   
11|1 7
12|1  
   
   D
7 15 70 70 82 84 93 111 117 121

If you try some real data you will probably notice differences between it and 
the real data that this generates.

Linda



-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Friday, May 16, 2014 11:20 PM
To: [email protected]
Subject: Re: [Jprogramming] Stemplot

Once this worked, I separated data arrays form functions and gave names to the 
steps. If you save this script it will generate random seets of date and 
product an appropriate stemplot.  Scroll back in the terminal or jijx to see 
how it was built.

NB.D=:/:~115 77 77 114 108 116 77  
D=:/:~ (>:?15)+?10#140

sl=: 13 :'''S L''=:|:0 10#:y'
sl D
S                                     NB. stems
L                                     NB. leaves

le=: 13 :'x ": /. y'                  NB.  leaf plot
]LE=:S le L

do=: 13 :'(<./y)+i.>:(>./y)-<./y'     NB. domain 
]DO=:do S

swl=: 13 :'":,.~.y'                   NB. stem with leaves
]SWL=:(swl S),.'|'

snl=: 13 :'":,.(-.(do y) e.y) # do y' NB. 
]SNL=:(snl S),.'|'

]SD=:|."1(|."1 SWL),|."1 SNL          NB. stem domain

]LSP=:S le L                          NB. leaf stem plot

]ALL=:SD,.LSP,((0{$SNL),1{$LE)$' '    NB. all parts of plot
   
os=: 13 :'(".0 1{"1 y)-<./do x'       NB. orderof stems
]OS=:S os ALL

go=: 13 :'x i.i. $do y'                NB. good order
]GO=:OS go S

NB. all tacit verbs
sl
le
do
swl
snl
os
go

]GOOD=:GO {"2 ALL                      NB. good stemplot

D

Linda


-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Friday, May 16, 2014 3:03 PM
To: [email protected]
Subject: Re: [Jprogramming] Stemplot

Yes,  I tried it and it worked. 

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Kip Murray
Sent: Friday, May 16, 2014 10:00 AM
To: [email protected]
Subject: Re: [Jprogramming] Stemplot

Did you notice I had  _  1  _  while you had  _1  _  ?

On Friday, May 16, 2014, Linda Alvord <[email protected]> wrote:

>  I got this far:
>
>    S=:2 2 2 3 4
>    L=:3 4 8 3 7
>
>    le2=: 13 :'(=x) ([: ": #)"_1 y'
>    S     le2 L
> |length error: le2
> |   S     le2 L
> |[-4] c:\users\owner\j801-user\temp\137.ijs
>
>
> But missed the second  _
>
>    le2=: 13 :'(=x) ([: ": #)"_1 _ y'
>    S     le2 L
> 3 4 8
> 3
> 7
>
> Then this woke me up.
>
>      5!:4 <'le2'
>   ┌─ ]
>   │                  ┌─ [:
>   │           ┌──────┼─ ":
> ──┼─ ~ ─── " ─┤      └─ #
>   │           └─ _1 _
>   │     ┌─ [:
>   └─────┼─ =
>         └─ [
>
>
> Thanks,  Linda
>
> -----Original Message-----
> From: [email protected] <javascript:;> [mailto:
> [email protected] <javascript:;>] On Behalf Of Kip
> Murray
> Sent: Friday, May 16, 2014 2:56 AM
> To: [email protected] <javascript:;>
> Subject: Re: [Jprogramming] Stemplot
>
> Try
>
>    le2=: 13 :'(=x) ([: ": #)"_ 1 _ y'
>    S le2 L
> 3 4 8
> 3
> 7
>
> You need to review the ranks of u@v and [: u v .  I used (":@#) b. 0 to
> find the ranks I used above.
>
> On Thursday, May 15, 2014, Linda Alvord 
> <[email protected]<javascript:;>>
> wrote:
>
> > Here's an odd behavior.  Why doesn't  le2  behave the same as  le3?
> >
> >
> > S=:2 2 2 3 4
> >
> > L=:3 4 8 3 7
> >
> >    NB.   x u/.y ↔ (=x) u@# y
> >
> >    le3=: 13 :'(=x) ":@ # y'
> >    ]LE3=: S le3 L
> > 3 4 8
> > 3
> > 7
> >
> >    le2=: 13 :'(=x) ([: ": #) y'
> >    ]LE2=: S le2 L
> > 3 4 8
> > 3 0 0
> > 7 0 0
> >
> >    le=: 13 :'x ": /. y'
> >    ]LE=:S le L
> > 3 4 8
> > 3
> > 7
> >
> > 5!:4 <'le3'
> >    5!:4 <'le3'
> >   ┌─ ]
> >   │           ┌─ ":
> >   ├─ ~ ─── @ ─┴─ #
> > ──┤
> >   │     ┌─ [:
> >   └─────┼─ =
> >         └─ [
> >
> >    5!:4 <'le2'
> >   ┌─ ]
> >   │          ┌─ [:
> >   ├─ ~ ──────┼─ ":
> > ──┤          └─ #
> >   │     ┌─ [:
> >   └─────┼─ =
> >         └─ [
> >
> >    5!:4 <'le'
> > ── /. ─── ":
> >
> > Linda
> >
> >
> >
> >
> > -----Original Message-----
> > From: [email protected] <javascript:;> [mailto:
> > programming- <javascript:;>
> > [email protected] <javascript:;>] On Behalf Of Linda Alvord
> > Sent: Tuesday, May 13, 2014 4:14 AM
> > To: [email protected]
> > Subject: Re: [Jprogramming] Stemplot
> >
> > Here's the first 4 lines with a line feed.  Linda
> >
> > D=:/:~ 17 133 151 47 12 19 52 80 32 87 24 14 20 90 9 47 72 7 36 64
> > NB.D=:/:~50 83 95 107 113 113 116 116 118 123
> > NB.D=:11 11 31 73 74 92 104 114 129 133
> > NB.D=:/:~ (>:?15)+?10#140
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Linda
> > Alvord
> > Sent: Monday, May 12, 2014 11:29 PM
> > To: [email protected]
> > Subject: Re: [Jprogramming] Stemplot
> >
> > Here's where this belongs.
> >
> > ip, I enjoyed this problem.  I created the following script to randomly
> > generate lists and then create the stemplot.  Save in a new jijx.  Then
> run
> > it.  Remove the  NB. in the second line to see another example. Do the
> same
> > for the third line.  Removing the NB. from the fourth line will generate
> > new
> > data.  Hopefully it won't fail.  Id appreciate inprovements within
> simple J
> > from anyone.
> >
> > D=:/:~ 17 133 151 47 12 19 52 80 32 87 24 14 20 90 9 47 72 7 36 64
> > NB.D=:/:~50 83 95 107 113 113 116 116 118 123
> > NB.D=:11 11 31 73 74 92 104 114 129 133
> > NB.D=:/:~ (>:?15)+?10#140
> >
> > sl=: 13 :'''S L''=:|:0 10#:y'
> > sl D
> > S
> > L
> >
> > ]DO=:(<./S)+i.>:(>./S)-<./S
> >
> > ]WL=:":,.(DO e. S)#DO
> >
> > ]WOL=:":,.(-.DO e. S)#DO
> >
> > ]SS=:(|."1(|."1 WL),|."1 WOL),.'|'
> >
> > ]LS=:S ":/. L
> >
> > ]NLS=:((0{$WOL),1{$LS)$' '
> >
> > ]SP=: SS,. LS, NLS
> >
> > ]OS=: (".0 1{"1 SS)-0{DO
> >
> > ]G=: OS i. i.$DO
> >
> > ]GOOD=:G {"2 SP
> >
> > ]D
> >
> > In these days I guess you could call it a stem plot "app".  In any case,
> > when you understand any steps you can remove  ]  from a given line and it
> > will no longer provide that result.  Eventually, if you remove them all,
> > you
> > can make a stem plot of two digit numbers. I would have able to develop
> > this
> > and then use it in a high school Probability and Statistics class.
> >
> > Linda
> >
> >
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Kip
> Murray
> > Sent: Wednesday, May 07, 2014 9:47 AM
> > To: [email protected]
> > Subject: Re: [Jprogramming] Stemplot
> >
> > You somehow lost the leaf 1 from data item 151 (an "off by 1" error?).
> >  Last row of answer should be 15 1 _ _ _  Sorry about line wrap.  --Kip
> >
> >    NB. Actually... this isn't any shorter, but it feels cleaner:
> >
> >    2-~(+1%*)/:~(~.@[,./:~@}:/.)/|:>:0 10#:data,10*i.>./<.data%10
> >  0 7 9 _ _
> >  1 2 4 7 9
> >  2 0 4 _ _
> >  3 2 6 _ _
> >  4 7 7 _ _
> >  5 2 _ _ _
> >  6 4 _ _ _
> >  7 2 _ _ _
> >  8 0 7 _ _
> >  9 0 _ _ _
> > 10 _ _ _ _
> > 11 _ _ _ _
> > 12 _ _ _ _
> > 13 3 _ _ _
> > 14 _ _ _ _
> > 15 _ _ _ _
> >
> >    NB. Thanks,
> >
> >    stemplot data
> >  0|7 9
> >  1|2 4 7 9
> >  2|0 4
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm



-- 
Sent from Gmail Mobile
----------------------------------------------------------------------
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

----------------------------------------------------------------------
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