A問題關於使用列名集。 您可以使用 JSL 的關聯數組來執行集合操作。 <
// make three sets
rgb = associativearray({"red","green","blue"});
cmy = associativearray({"cyan","magenta","yellow"});
bw = associativearray({"black","white"});
// join them together
all = rgb;
all<<INSERT></INSERT>
問題是根據列名的集合提出的,本範例使用關聯數組集合運算<<刪除取得所有列的集合與包含字母「i」的列的集合之間的差異。
// keep only the columns with an "i" in the name
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
allnames = dt << getcolumnnames( "string" );
inames = {};
For( i = 1, i <= N Items( allnames ), i++,
If( Contains( allnames[i], "i" ),
Insert Into( inames, allnames[i] )
)
);
allset = Associative Array( allnames ); // {"name", "age", "sex", "height", "weight"}
iset = Associative Array( inames ); // {"height", "weight"}
allset << Remove( iset ); // the "not i" set...
notinames = allset<<GETKEYS></GETKEYS>
Overlapping red, green, blue ringsOverlapping red, green, blue ringsOverlapping red, green, blue ringsOverlapping red, green, blue rings重疊的紅、綠、藍環
使用關聯數組作為集合。 相交、並集、差集。
這非常好。我沒想過要使用這樣的關聯數組。我過去曾遇到過使用物件參考清單的情況,並且我想搜尋該清單以消除滿足某些條件的物件。使用清單操作非常慢且控制邏輯很複雜。我可以看到這會讓事情變得更容易。我正在複製並貼上您的範例程式碼以添加到我的“JSL 集合”中以供將來參考!