|
@@ -2961,6 +2961,47 @@ messageSends: ["new", "class", "keysAndValuesDo:", "ifTrue:", "value:", "at:put:
|
|
|
}),
|
|
|
$globals.AssociativeCollection);
|
|
|
|
|
|
+$core.addMethod(
|
|
|
+$core.method({
|
|
|
+selector: "select:thenCollect:",
|
|
|
+protocol: "enumerating",
|
|
|
+fn: function (selectBlock,collectBlock){
|
|
|
+var self=this;
|
|
|
+var newDict;
|
|
|
+
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
+
|
|
|
+var $1;
|
|
|
+newDict=$recv(self._class())._new();
|
|
|
+self._keysAndValuesDo_((function(key,value){
|
|
|
+
|
|
|
+return $core.withContext(function($ctx2) {
|
|
|
+
|
|
|
+$1=$recv(selectBlock)._value_(value);
|
|
|
+
|
|
|
+$ctx2.sendIdx["value:"]=1;
|
|
|
+
|
|
|
+if($core.assert($1)){
|
|
|
+return $recv(newDict)._at_put_(key,$recv(collectBlock)._value_(value));
|
|
|
+}
|
|
|
+
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)});
|
|
|
+
|
|
|
+}));
|
|
|
+return newDict;
|
|
|
+
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"select:thenCollect:",{selectBlock:selectBlock,collectBlock:collectBlock,newDict:newDict},$globals.AssociativeCollection)});
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+args: ["selectBlock", "collectBlock"],
|
|
|
+source: "select: selectBlock thenCollect: collectBlock\x0a\x09| newDict |\x0a\x09newDict := self class new.\x0a\x09self keysAndValuesDo: [ :key :value |\x0a\x09\x09(selectBlock value: value) ifTrue: [ newDict at: key put: (collectBlock value: value) ]].\x0a\x09^ newDict",
|
|
|
+referencedClasses: [],
|
|
|
+
|
|
|
+messageSends: ["new", "class", "keysAndValuesDo:", "ifTrue:", "value:", "at:put:"]
|
|
|
+}),
|
|
|
+$globals.AssociativeCollection);
|
|
|
+
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "shallowCopy",
|
|
@@ -8603,6 +8644,47 @@ messageSends: ["new", "class", "do:", "ifTrue:", "value:", "add:"]
|
|
|
}),
|
|
|
$globals.Set);
|
|
|
|
|
|
+$core.addMethod(
|
|
|
+$core.method({
|
|
|
+selector: "select:thenCollect:",
|
|
|
+protocol: "enumerating",
|
|
|
+fn: function (selectBlock,collectBlock){
|
|
|
+var self=this;
|
|
|
+var collection;
|
|
|
+
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
+
|
|
|
+var $1;
|
|
|
+collection=$recv(self._class())._new();
|
|
|
+self._do_((function(each){
|
|
|
+
|
|
|
+return $core.withContext(function($ctx2) {
|
|
|
+
|
|
|
+$1=$recv(selectBlock)._value_(each);
|
|
|
+
|
|
|
+$ctx2.sendIdx["value:"]=1;
|
|
|
+
|
|
|
+if($core.assert($1)){
|
|
|
+return $recv(collection)._add_($recv(collectBlock)._value_(each));
|
|
|
+}
|
|
|
+
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
|
|
|
+
|
|
|
+}));
|
|
|
+return collection;
|
|
|
+
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"select:thenCollect:",{selectBlock:selectBlock,collectBlock:collectBlock,collection:collection},$globals.Set)});
|
|
|
+
|
|
|
+},
|
|
|
+
|
|
|
+args: ["selectBlock", "collectBlock"],
|
|
|
+source: "select: selectBlock thenCollect: collectBlock\x0a\x09| collection |\x0a\x09collection := self class new.\x0a\x09self do: [ :each |\x0a\x09\x09(selectBlock value: each) ifTrue: [\x0a\x09\x09\x09collection add: (collectBlock value: each) ] ].\x0a\x09^ collection",
|
|
|
+referencedClasses: [],
|
|
|
+
|
|
|
+messageSends: ["new", "class", "do:", "ifTrue:", "value:", "add:"]
|
|
|
+}),
|
|
|
+$globals.Set);
|
|
|
+
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "size",
|