This discussion on sets seems to be strictly on FINITE sets. No infinite set is 
represented by an array in J. Right?

A finite sets are conveniently represented by characteristic function also 
called an indicator function, where f(x)=1 if x is an element of the set, and 
f(x)=0 otherwise.

In J indicator functions are implemented simply bit arrays, which are easily 
manipulated in J. What is the problem?



--- Den ons 5/8/09 skrev Kip Murray <[email protected]>:

> Fra: Kip Murray <[email protected]>
> Emne: Re: [Jprogramming] J Sets
> Til: "Programming forum" <[email protected]>
> Dato: onsdag 5. august 2009 10.56
> Fraser, sortSet is beautiful.
> 
>     isSet =: -:&sortSet
> 
>     (powSet 'abcd') isSet powSet 'bdca'
> 1
>     'abcd' isSet 'bdcaa'
> 1
> 
> 
> Revision:
> 
> Question 1: What is a set?
>    Answer: A set is an array.
> 
> Question 2: What is an element of a set?
>    Answer: If the set is open, an element is
> an item of the set.  If the set is
>            boxed, an
> element is the open of an atom of the set.
> 
> 
> About creating new data objects, I plead guilty, especially
> if you are referring 
> to my response to Raul's puzzle.
> 
> Kip
> 
> 
> Fraser Jackson wrote:
> > Kip,
> > 
> > You seem to keep wanting to create new data objects
> when I do not believe 
> > they are necessary.
> > 
> > In J it is perfectly possible to have a sequence and a
> set having exactly 
> > the same representation.  A lot of set theory is
> concerned with sequences. 
> > They may be sequences of atoms, or sequences of
> sets.  Having set verbs and 
> > sequence verbs operating on these objects is the
> direction I would go.  That 
> > means of course that the order of items in the list of
> elements may matter.
> > 
> > At an earlier stage in this discussion you suggested
> that it would be 
> > difficult to sort elements and test identity in sets
> of sets if the elements 
> > were not in a standard order.
> > 
> > I think the following function will achieve that by
> sorting into a J sort 
> > order.  That provides a standard form to simplify
> testing.  Raul might 
> > provide a tacit form.
> > 
> >    sortSet =: 3 : 0
> > s =. y
> > for_k. i. >: L. y do.   s =. Set L:k
> s end.
> > )
> > 
> > The following gives an example of what it does  -
> you need to copy and 
> > execute it to see its results - my mailer seems to
> really mishandle boxing.
> > 
> >    s1 =: 'bdca'
> >    s2 =: powSet s1
> >    s2a =: 0 13 3 6 {s2
> >    s2b =: 1 13 5 2 {s2
> >    s3a =:  2 5 9 13 { powSet s2a
> >    s3b =:  2 5 9 13 { powSet s2b
> > 
> >    sc =:  |. s1;s2a;<s3a
> >    sd =:  |. s1;s2b;<s3b
> > 
> >     sc
> >    sortSet sc
> >    sd
> >    sortSet sd
> > 
> > You can get other results by converting sortSet to a
> dyadic verb and 
> > specifying the levels at which sorting will be done.
> > 
> > Fraser
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>




      Trænger du til at se det store billede? Kelkoo giver dig gode tilbud på 
LCD TV! Se her http://dk.yahoo.com/r/pat/lcd
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to