Difference between revisions of "Set Functions"
(Created page with 'Category:Set Functions ''new to Analytica 4.3'' In mathematics, a ''set'' is a collection of non-repeated elements. The functions described on this page operate on sets tha…') |
|||
Line 1: | Line 1: | ||
[[Category:Set Functions]] | [[Category:Set Functions]] | ||
''new to Analytica 4.3'' | ''new to Analytica 4.3'' | ||
+ | |||
+ | = Sets = | ||
In mathematics, a ''set'' is a collection of non-repeated elements. The functions described on this page operate on sets that are represented in Analytica as a [[Using References|reference]] to list or 1-D array. With this representation, a set is seen as an atomic element by Analytica's array abstraction, thus allowing all these functions to fully array abstract even when the collections comprising the sets are of different lengths or have different indexes. | In mathematics, a ''set'' is a collection of non-repeated elements. The functions described on this page operate on sets that are represented in Analytica as a [[Using References|reference]] to list or 1-D array. With this representation, a set is seen as an atomic element by Analytica's array abstraction, thus allowing all these functions to fully array abstract even when the collections comprising the sets are of different lengths or have different indexes. | ||
Line 13: | Line 15: | ||
Suppose you have a 4-dimensional array, A, indexed by In1, In2, In3 and In4. The expression <code>\[In4]A</code> returns a 3-D array of sets, each set being one of the vectors indexed by In4. As seen, when using the [[Using References|reference operator, \]] you can specify in brackets which index becomes the ''set dimension''. | Suppose you have a 4-dimensional array, A, indexed by In1, In2, In3 and In4. The expression <code>\[In4]A</code> returns a 3-D array of sets, each set being one of the vectors indexed by In4. As seen, when using the [[Using References|reference operator, \]] you can specify in brackets which index becomes the ''set dimension''. | ||
+ | |||
+ | == Literal Sets == | ||
To create a set from a literal list, you must either specify the ''Null dimension'' to the [[Using References|reference operator]], or you must surround the brackets by parentheses. You cannot simply place a backslash in front of a literal list, since the [[Using References|backslash operator]] sees brackets and assumes that the brackets are specifying the indexes to swallow. Here are two examples of how to express a literal set: | To create a set from a literal list, you must either specify the ''Null dimension'' to the [[Using References|reference operator]], or you must surround the brackets by parentheses. You cannot simply place a backslash in front of a literal list, since the [[Using References|backslash operator]] sees brackets and assumes that the brackets are specifying the indexes to swallow. Here are two examples of how to express a literal set: | ||
− | [[Using References|\]][[[Null]]][1,2,3] | + | [[Using References|\]][ [[Null]] ][1,2,3] |
[[Using References|\]]([1,2,3]) | [[Using References|\]]([1,2,3]) | ||
+ | but | ||
+ | [[Using References|\]][1,2,3] { **** Does not work **** } | ||
+ | == Converting a Set to a List == | ||
+ | |||
+ | The [[Using References|dereference operator, #]] is used to convert a set back into a list. This operation does not array-abstract, so you can apply it to a single set, but not to an array of sets. | ||
= SetContains = | = SetContains = | ||
Line 25: | Line 34: | ||
Returns true if element is contained in the set. | Returns true if element is contained in the set. | ||
+ | |||
+ | = SetsAreEqual = | ||
+ | |||
+ | Function SetsAreEqual( sets'', I, ignoreNulls'' ) | ||
= SetIntersection = | = SetIntersection = | ||
Line 36: | Line 49: | ||
= SetDifference = | = SetDifference = | ||
− | Function SetDifference( originalSet, remove'', | + | Function SetDifference( originalSet, remove'', remove2, remove3, ..., resultIndex, keepNull'') |
Revision as of 18:10, 30 March 2010
new to Analytica 4.3
Sets
In mathematics, a set is a collection of non-repeated elements. The functions described on this page operate on sets that are represented in Analytica as a reference to list or 1-D array. With this representation, a set is seen as an atomic element by Analytica's array abstraction, thus allowing all these functions to fully array abstract even when the collections comprising the sets are of different lengths or have different indexes.
The following demonstrates this representation:
Var A_list := ['a','b','c','d']; Var A_set := \A_list; ...
The backslash in front of A_list turns the list into a set in the manner expected by functions here.
Suppose you have a 4-dimensional array, A, indexed by In1, In2, In3 and In4. The expression \[In4]A
returns a 3-D array of sets, each set being one of the vectors indexed by In4. As seen, when using the reference operator, \ you can specify in brackets which index becomes the set dimension.
Literal Sets
To create a set from a literal list, you must either specify the Null dimension to the reference operator, or you must surround the brackets by parentheses. You cannot simply place a backslash in front of a literal list, since the backslash operator sees brackets and assumes that the brackets are specifying the indexes to swallow. Here are two examples of how to express a literal set:
\[ Null ][1,2,3] \([1,2,3])
but
\[1,2,3] { **** Does not work **** }
Converting a Set to a List
The dereference operator, # is used to convert a set back into a list. This operation does not array-abstract, so you can apply it to a single set, but not to an array of sets.
SetContains
Function SetContains( set, element )
Returns true if element is contained in the set.
SetsAreEqual
Function SetsAreEqual( sets, I, ignoreNulls )
SetIntersection
Function SetUnion( sets, I, resultIndex, keepNulls )
SetUnion
Function SetUnion( sets, I, resultIndex, keepNulls )
SetDifference
Function SetDifference( originalSet, remove, remove2, remove3, ..., resultIndex, keepNull)
Enable comment auto-refresher