Linda, Rich,

Thanks, I will check how you did these in dissect tomorrow. I'm kind of 
surprised the answers are so short. I tried for a while to make a tacit verb 
but failed, so fell back to the imperative verbs. 

Thanks!

--------------------------------------------
On Sun, 9/27/15, Linda A Alvord <[email protected]> wrote:

 Subject: Re: [Jprogramming] Generate Complete Graphs
 To: [email protected]
 Date: Sunday, September 27, 2015, 12:47 AM
 
 comb=: 13
 :'(x=+/"1 #:i.2^y) ([:|.[:I.#) #:i.2^y'
    2 comb 5
 0 1
 0 2
 0 3
 0 4
 1 2
 1 3
 1 4
 2 3
 2 4
 3 4
    
    3
 comb 4
 0 1 2
 0 1 3
 0 2 3
 1 2 3
    
 
 -----Original Message-----
 From: [email protected]
 [mailto:[email protected]]
 On Behalf Of Henry Rich
 Sent: Saturday,
 September 26, 2015 11:12 AM
 To: [email protected]
 Subject: Re: [Jprogramming] Generate Complete
 Graphs
 
 ; <@({. ,. }.)\.@i. 5
 
 
 
 (#~
 </"1) (#: i.@(*/)) 2 $ 5
 
 Henry Rich
 
 On
 9/26/2015 9:24 AM, 'Jon Hough' via Programming
 wrote:
 > Sorry, the second verb should
 be
 >
 > getEdges =: 3 :
 0
 > if. 1 > # y do.
 >
 > else.
 > h =. 1{.y
 > t =.
 1}.y
 > ((h&,)"0 t ), getEdges
 t
 > end.
 > )
 >
 > (changed getNodes to
 getEdges)
 >
 >
 >
 --------------------------------------------
 > On Sat, 9/26/15, 'Jon Hough' via
 Programming <[email protected]>
 wrote:
 >
 >   Subject: [Jprogramming]
 Generate Complete Graphs
 >   To: "Programming
 Forum" <[email protected]>
 >   Date: Saturday, September 26,
 2015, 10:16 PM
 >   
 >   I have a couple of verbs to
 represent
 >   a complete
 (undirected) graph as a list of edges. Clearly
 >   there are "N choose
 2" edges that need to be generated. This
 >   is my code
 >   
 >   complete =: 3 : 0
 >   nodes =. i. y
 >   getEdges nodes
 >   )
 >   
 >   getEdges =: 3 : 0
 >   if. 1 > # y do.
 >   
 >   else.
 >   h =. 1{.y
 >   t =. 1}.y
 >   ((h&,)"0 t ),
 getNodes t
 >   end.
 >   )
 >   
 >   
 >   e.g. I can get the 10 edges
 of the graph K5 by doing
 >   
 >   complete 5
 >   
 >   My above code is ugly
 however. To be specific, it seems too
 >   imperative for J,  and the
 first part of the if. do. in
 >   getEdges doesn't return
 anything which seems ugly.
 >   
 >   I would like to know if there
 is a more J-like, terse way to
 >   do this.
 >   
 >   Regards,
 >   Jon
 >   ----------------------------------------------------------------------
 >   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