/usr/share/yacas/scripts/assoc.rep/code.ys is in yacas 1.3.6-2+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /* Assoc : given an assoc list like for example l:={{a,2},{b,3}},
Assoc(b,l) will return {b,3}. if the key is not in the list,
it will return the atom Empty.
*/
Function("Assoc",{key,list}) Builtin'Assoc(key,list);
AssocIndices(associndiceslist_IsList) <--
DestructiveReverse(MapSingle("Head",associndiceslist));
/// Delete an element of an associative list.
LocalSymbols(hash, key, element, hash'expr)
[
/// AssocDelete(hash,{"key", value})
10 # AssocDelete(hash_IsList, element_IsList) <--
[
Local(index);
index := Find(hash, element);
If(
index > 0,
DestructiveDelete(hash, index)
);
index>0; // return False if nothing found
];
/// AssocDelete(hash, "key")
20 # AssocDelete(hash_IsList, key_IsString) <--
[
AssocDelete(hash, Builtin'Assoc(key, hash));
];
30 # AssocDelete(hash_IsList, Empty) <-- False;
//HoldArg("AssocDelete", hash);
//UnFence("AssocDelete", 1);
//UnFence("AssocDelete", 2);
]; // LocalSymbols(hash, ...)
|