How do I make properties(...) work within a function definition?
Subject: How do I make properties(...) work within a function definition?
From: David R Stoutemyer
Date: Wed, 02 Nov 2011 09:05:56 -1000
/* I want to programmatically do examples such as the following to see if "nary" is a member of the property list: */
properties("+");
["mirror symmetry", nary, rule, operator]
/* But I want to obtain the properties of symbols or strings from within a function definition, without knowing the particular symbol in advance. Here is a minimal such function definition: */
propertyList(symbolOrString) := properties(symbolOrString)$
/* It doesn't work because evidently properties(...) quotes its argument: */
propertyList("+");
[value]
/* Using the quote quote operator on the top-level argument doesn't work because the parser evaluates it, which is too soon: */
propertyList(''"+");
[value]
/* Putting the quote quote inside the body of the function definition doesn't work because the parser
evaluates it there too: */
propertyList(operator) := properties(''operator)$
propertyList("+");
[value]
/* The ev(...) function causes an error message for reasons that are unclear to me: */
propertyList(operator) := properties(ev(operator))$
propertyList("+");
properties: argument must be a symbol or a string.
#0: propertyList(operator=+)
-- an error. To debug this try: debugmode(true);
/* I wish that for every function that quotes an argument as a "convenience" there was a
corresponding version that didn't! Is there a way to do what I want? */