List-based sets

Help Contents Logo and Languages List-based sets
I don't want it all. I need just a bit of it. ( first, last, bf, bl, item ) Other actions (count, ascii, char, wait )

List-based sets

member, memberP, sunion, ssection, sminus

There is another group of functions which will help you to treat lists as mathematical sets and to perform set-oriented actions.

The function member? checks wether a value is an element of a list.

A similar function is member - it will not only check the same, but will return a list containing the elements from the found occurence of an element till the end of the list.
	print member? "x [a d x o p] ; true
	print member "x [a d x o p] ; [x o p]
There are more advanced list-based set functions for finding union, intersection and difference of sets.

Let's have variable Mary containing all things that Mary can do and another list - John - for the things he can do.

What either of them can do is found with function sunion, (comes from set union), because this is the union of both sets.

The intersection, i.e. what they can both do, is calculated by ssection (from set intersection).

And finally, the difference is found via sminus (from set minus) and it represents what, for example, Mary can do that John cannot.
	make "Mary [sing paint jump]
	make "John [jump play]
	print sunion :Mary :John ; [jump play sing paint]
	print ssection :Mary :John ; [jump]
	print sminus :Mary :John ; [sing paint]

I don't want it all. I need just a bit of it. ( first, last, bf, bl, item ) Other actions (count, ascii, char, wait )