Hello,
This series of enhancement topics you started recently is really usefull
It would be nice to have some examples showing the use of SET operators in expressions and as single operands
eg:
u:= s- {8,9,13} if s:={7,9,14}
u:= -s
not so clear for me the use of IS an the TYPE "Tree"
Regards
Alain
SET operators
-
- Site Admin
- Posts: 502
- Joined: Fri Dec 31, 2010 12:30 pm
- Contact:
Re: SET operators
Thank you for your feedback - much appreciated. There's a lot more to come if there is sufficient interest
Niklaus Wirth has written a paper on the use of SETs titled "SET: A neglected data type and its compilation for the ARM". You can download a copy from:
https://people.inf.ethz.ch/~wirth/Oberon/SETs.pdf
When you subtract one set from another, any element that is common to both sets is removed. No other element is affected.
Thus, if you execute the code:
then u = {7, 14};
-SET is the complement of a set. i.e. the resulting set contains all the elements that were not in the original set and none of the elements that were in the original set.
If s = {7, 9, 14} then -s = {0,1,2,3,4,5,6,8,10,11,12,13,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}
This is more conveniently written as {0..6, 8, 10..13, 15..31}
Niklaus Wirth has written a paper on the use of SETs titled "SET: A neglected data type and its compilation for the ARM". You can download a copy from:
https://people.inf.ethz.ch/~wirth/Oberon/SETs.pdf
When you subtract one set from another, any element that is common to both sets is removed. No other element is affected.
Thus, if you execute the code:
Code: Select all
s := {7,9,14};
u := s - {8,9,13};
-SET is the complement of a set. i.e. the resulting set contains all the elements that were not in the original set and none of the elements that were in the original set.
If s = {7, 9, 14} then -s = {0,1,2,3,4,5,6,8,10,11,12,13,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}
This is more conveniently written as {0..6, 8, 10..13, 15..31}
Last edited by cfbsoftware on Thu Apr 18, 2024 12:19 am, edited 1 time in total.
Reason: Updated the link to Wirtj's article
Reason: Updated the link to Wirtj's article