Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
43
Task/Set/BBC-BASIC/set.basic
Normal file
43
Task/Set/BBC-BASIC/set.basic
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
DIM list$(6)
|
||||
list$() = "apple", "banana", "cherry", "date", "elderberry", "fig", "grape"
|
||||
|
||||
setA% = %1010101
|
||||
PRINT "Set A: " FNlistset(list$(), setA%)
|
||||
setB% = %0111110
|
||||
PRINT "Set B: " FNlistset(list$(), setB%)
|
||||
elementM% = %0000010
|
||||
PRINT "Element M: " FNlistset(list$(), elementM%) '
|
||||
|
||||
IF elementM% AND setA% THEN
|
||||
PRINT "M is an element of set A"
|
||||
ELSE
|
||||
PRINT "M is not an element of set A"
|
||||
ENDIF
|
||||
IF elementM% AND setB% THEN
|
||||
PRINT "M is an element of set B"
|
||||
ELSE
|
||||
PRINT "M is not an element of set B"
|
||||
ENDIF
|
||||
|
||||
PRINT '"The union of A and B is " FNlistset(list$(), setA% OR setB%)
|
||||
PRINT "The intersection of A and B is " FNlistset(list$(), setA% AND setB%)
|
||||
PRINT "The difference of A and B is " FNlistset(list$(), setA% AND NOT setB%)
|
||||
|
||||
IF (setA% AND setB%) = setA% THEN
|
||||
PRINT '"Set A is a subset of set B"
|
||||
ELSE
|
||||
PRINT '"Set A is not a subset of set B"
|
||||
ENDIF
|
||||
IF setA% = setB% THEN
|
||||
PRINT "Set A is equal to set B"
|
||||
ELSE
|
||||
PRINT "Set A is not equal to set B"
|
||||
ENDIF
|
||||
END
|
||||
|
||||
DEF FNlistset(list$(), set%)
|
||||
LOCAL i%, o$
|
||||
FOR i% = 0 TO 31
|
||||
IF set% AND 1 << i% o$ += list$(i%) + ", "
|
||||
NEXT
|
||||
= LEFT$(LEFT$(o$))
|
||||
Loading…
Add table
Add a link
Reference in a new issue