Kip Murray wrote:
>
> [...]
> E =: ,a: NB. empty set
> set =: a: ,~ [: /:~ ~. NB. create set from boxed list y
> NB. each box of y encloses an element
> get =: { }: NB. get boxed elements (from curtail because
> NB. elements are inside boxes of curtail)
> isin =: e. }: NB. Do boxes in list x contain elements of y?
> less =: a: ,~ -.&}: NB. remove elements of y from x
> sand =: [ less less NB. intersection, "set and"
> sor =: a: ,~ [: /:~ [: ~. ,&}: NB. union, "set or"
> diff =: less sor less~ NB. symmetric difference
> card =: [: # }: NB. count elements: cardinality
> issubs =: [ -: sand NB. Is x a subset of y?
> pwrset =: a: ,~ [: /:~ ] (<@#~) 1 (,~"1) 2 (#"1~ {:)@#:@i...@^ #...@}:
> NB. pwrset by Raul Miller, adapted
> islist =: 1 = #...@$ NB. islist through isunique from validate.ijs
> isboxed =: 0 < L.
> issorted =: -: /:~
> isunique =: -: ~.
> isset =: islist *. isboxed *. (a: -: {:) *. issorted@:}: *. isunique@:}:
> NB. isset y asks, is array y a set?
> iselement =: <@[ isin ] NB. Is array x an element of set y?
>
> [...]
>
Simpler formulation of sor:
sor1=: set@,&}:
Simpler formulation of isset:
isset1 =: -: s...@}: NB. is y set ?
NB. is x representing set y? (this is
equiv. to -:)
--
View this message in context:
http://old.nabble.com/Puzzle%3A-line-circle-sphere-intersection-tp29900737s24193p29933179.html
Sent from the J Programming mailing list archive at Nabble.com.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm