blob: 1a3e5b1f916e9e84f5a958a693a564318b583fb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
Creating a set:\\
{\ex \lstinline| p10 = set([2, 3, 5, 7]) |t}
Creating set from a tuple or list:\\
{\ex \lstinline| s = set(var_name)|}
Operations on sets. Ex: UNION:\\
{\ex \lstinline| s1 \| s2 |}
Other operations available:\\
\begin{lstlisting}
\item "\&" -- Intersection
\item "-" -- Difference
\item "\^" -- Symmetric Difference
\item "<" -- Subset
\end{lstlisting}
Checking for containership:\\
{\ex \lstinline| x in p10|}
Finding the no.of elements:\\
{\ex \lstinline| len(p10)|}
|