I am trying to implement custom options in my code manually, rather than using the built-in Options
tools. So I have functions that look like f[x_,y_,opts___]
where opts
is intended to be a (possibly empty) list or sequence of rules.
I'd like to be able to enter opts
as a sequence or list, but I'm having a very hard time getting my code to cover both cases. How can I program my functions so that opts
is converted to a list of rules, regardless of whether they are fed into the function as a list or sequence?
Flatten
in case it already was a list, i.e.,options = {opts} // Flatten
$\endgroup$ – Bob Hanlon Dec 1 '20 at 18:00Range->{0,10}
. Won'tFlatten
ruin this? $\endgroup$ – WillG Dec 1 '20 at 18:02Flatten
$\endgroup$ – WillG Dec 1 '20 at 18:03Rule[a,b]
FullForm
. $\endgroup$ – CA Trevillian Dec 1 '20 at 18:37Options
& Co don't cover, then perhaps ask a question about that. I always worry that these questions might stem from an XY problem. $\endgroup$ – MarcoB Dec 1 '20 at 19:11