From: jhmeyers@miu.edu (John H Meyers)
Newsgroups: comp.sys.hp48
Subject: Re: Set operations on lists (groups theory?)
Date: 1 Sep 1998 07:56:02 GMT
Organization: MIU Computer Services,  Fairfield, IA 52557.  Not Approved.
Lines: 55
Message-ID: <6sg9ai$fef$1@news.iastate.edu>
References: <6sbph7$o90$1@news.netvision.net.il>
Reply-To: jhmeyers@miu.edu
NNTP-Posting-Host: vax1.mum.edu
Xref: republic.btigate.com comp.sys.hp48:15328

In article <6sbph7$o90$1@news.netvision.net.il>,
"Doron Aloni" <dorona@butterfly.com> writes:

> Are there built in functions for Groups { x y z }
> like union, intersection, etc.
> or is there a way to define such operations, on the HP48GX ?

If you mean operations on sets of objects represented by lists:

%%HP: T(3); @ Miscellaneous list operations

@ Arguments and results may be empty lists.

{ { } } @ An object not expected to be in any list
        @ (used to prevent empty lists with DOLIST)

'Lnob' STO

@ The next two functions use the previous object:

@ { list1 } { list2 } ==> { intersection }
\<< Lnob SWAP OVER + \-> x
  \<< SWAP + 1 \<< x OVER POS NOT { DROP } IFT
    \>> DOLIST 2 OVER SIZE SUB \>> \>>

'L1a2' STO @ List1 <and> List2

@ { list1 } { list2 } ==> { in list1, but not in list2 }
\<< \-> x
  \<< Lnob SWAP + 1 \<< x OVER POS { DROP } IFT
    \>> DOLIST 2 OVER SIZE SUB \>> \>>

'L1n2' STO @ List1 <not> List2

@ The next two functions use the previous function:

@ { list1 } { list2 } ==> { union }
\<< OVER L1n2 + \>>

'L1o2' STO @ List1 <or> List2

@ { list1 } { list2 } ==> { in list1 or list2, but not both }
\<< DUP2 L1n2 SWAP ROT L1n2 + \>>

'L1x2' STO @ List1 <xor> List2

@ { list, with possible repeats } ==> { list, with no repeats }
\<< IF DUP SIZE THEN { } SWAP 1
  \<< IF DUP2 POS THEN DROP ELSE 1 \->LIST + END \>> DOLIST END \>>
@ 1 \->LIST allows list elements themselves to be lists

'Luni' STO

-----------------------------------------------------------
With best wishes from:   John H Meyers   <jhmeyers@mum.edu>