Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
23
Task/Symmetric-difference/Forth/symmetric-difference.fth
Normal file
23
Task/Symmetric-difference/Forth/symmetric-difference.fth
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
: elm ( n -- ; one cell per set )
|
||||
[ cell 8 * 1- ] literal umin CREATE 1 swap lshift ,
|
||||
DOES> ( -- 2^n ) @ ;
|
||||
|
||||
: universe ( u "name" -- )
|
||||
dup 0 DO I elm latest swap LOOP
|
||||
CREATE dup , 0 DO , LOOP
|
||||
DOES> ( n a -- ) dup @ tuck cells +
|
||||
swap 0
|
||||
DO ( n a' )
|
||||
over I rshift 1 AND
|
||||
IF dup @ name>string space type THEN
|
||||
1 cells -
|
||||
LOOP 2drop ;
|
||||
|
||||
5 universe john bob mary serena jim persons
|
||||
john bob mary serena or or or
|
||||
jim mary john bob or or or
|
||||
|
||||
2dup xor persons
|
||||
2dup -1 xor and cr persons
|
||||
swap -1 xor and cr persons
|
||||
cr bye
|
||||
Loading…
Add table
Add a link
Reference in a new issue