Changeset c8a8007 in tol
- Timestamp:
- Apr 16, 2009, 10:52:14 AM (18 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- d57ccd8
- Parents:
- 5095b2a
- File:
-
- 1 edited
-
tol/stdlib/general/grammars/_set.tol (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/general/grammars/_set.tol
r5095b2a rc8a8007 1252 1252 ////////////////////////////////////////////////////////////////////////////// 1253 1253 1254 1255 ////////////////////////////////////////////////////////////////////////////// 1256 Set SelectIndexByName(Set a, Set b) 1257 ////////////////////////////////////////////////////////////////////////////// 1258 { 1259 Real a.card = Card(a); 1260 Real b.card = Card(b); 1261 Case(Or(!a.card,!b.card), 1262 { 1263 Copy(Empty) 1264 }, 1265 Or(!HasIndexByName(b)), 1266 { 1267 WriteLn(I2( 1268 "Cannot apply SelectIndexByName to a non indexed by name set 'b'.", 1269 "No se puede aplicar SelectIndexByName a un conjunto 'b' no " 1270 "indexados por nombre."), 1271 "E"); 1272 Copy(Empty) 1273 }, 1274 1==1, 1275 { 1276 Real GT0 (Real idx) { idx>0 }; 1277 Set idx = EvalSet(a, Real(Anything obj) 1278 { 1279 FindIndexByName(b, Name(obj)) 1280 }); 1281 Select(idx, GT0) 1282 }) 1283 }; 1284 ////////////////////////////////////////////////////////////////////////////// 1285 PutDescription(I2( 1286 "Returns the set of indexes of elements of 'a' which there is in indexed by " 1287 "name set 'b' an element with the same name.", 1288 "Devuelve el conjunto de índices de los elementos 'a' tales que en el " 1289 "conjunto indexado por nombre 'b' existe un elemento del mismo nombre.\n"), 1290 SelectIndexByName); 1291 ////////////////////////////////////////////////////////////////////////////// 1292 1293 1294 ////////////////////////////////////////////////////////////////////////////// 1295 Set IntersectIndexByName(Set a, Set b) 1296 ////////////////////////////////////////////////////////////////////////////// 1297 { 1298 Real a.card = Card(a); 1299 Real b.card = Card(b); 1300 Case( 1301 Or(!HasIndexByName(a), !HasIndexByName(b)), 1302 { 1303 WriteLn(I2( 1304 "Cannot apply IntersectIndexByName to non indexed by name sets.", 1305 "No se puede aplicar IntersectIndexByName a conjuntos no " 1306 "indexados por nombre."), 1307 "E"); 1308 Copy(Empty) 1309 }, 1310 a.card > b.card, 1311 { 1312 Set selIdx = SelectIndexByName(b, a); 1313 ExtractByIndex(a, selIdx) 1314 }, 1315 1==1, 1316 { 1317 Set selIdx = SelectIndexByName(a, b); 1318 ExtractByIndex(b, selIdx) 1319 }) 1320 }; 1321 ////////////////////////////////////////////////////////////////////////////// 1322 PutDescription(I2( 1323 "Returns intersection of two sets that are indexed by name", 1324 "Devuelve la intersección de dos conjuntos indexados por nombre"), 1325 IntersectIndexByName); 1326 ////////////////////////////////////////////////////////////////////////////// 1327 1328 1329 ////////////////////////////////////////////////////////////////////////////// 1330 Set SetTolNameAndIndex(Set names) 1331 ////////////////////////////////////////////////////////////////////////////// 1332 { 1333 Real n = Card(names); 1334 Set aux = For(1, n, Text(Real k) 1335 { 1336 Eval(ToName(names[k])+"=\""+names[k]+"\"") 1337 }); 1338 Real If(n, SetIndexByName(aux)); 1339 aux 1340 }; 1341 ////////////////////////////////////////////////////////////////////////////// 1342 PutDescription(I2( 1343 "Put valid TOL names to a set of texts and indexes it", 1344 "Pone nombres válidos a un conjunto de textos y lo indexa"), 1345 SetTolNameAndIndex); 1346 ////////////////////////////////////////////////////////////////////////////// 1347 1348
Note: See TracChangeset
for help on using the changeset viewer.
