The only reason for the list in msup([a, 2]): it’s a html tag, so it will be translated to
<msup><mi>a</mi><mn>2</mn></msup>
I agree it doesn’t make much sense in another context.
The only reason for the list in msup([a, 2]): it’s a html tag, so it will be translated to
<msup><mi>a</mi><mn>2</mn></msup>
I agree it doesn’t make much sense in another context.
I think you can create a wrapper predicate to enumerate args like a list – and I guess one can also envision a non-deterministic member predicate applied to args.
Something like this, perhaps:
arg_member(Value, Term) :-
ground(Term),
functor(Term, _, Arity),
between(1, Arity, Arg),
arg(Arg, Term, Value).
Dan
We are drifting away a bit, but I am not sure if this definition is necessary. What is it that you are getting that you don’t get with arg/3 already?
Like this:
?- arg(_, foo(a, b, c), X).
X = a ;
X = b ;
X = c.
?- arg(_, foo(a, B, c), X).
X = a ;
B = X ;
X = c.
?- arg(_, Foo, X).
ERROR: Arguments are not sufficiently instantiated
?- arg(_, foo, X).
ERROR: Type error: `compound' expected, found `foo' (an atom)
The only difference is that this (correctly) has an error if your term is not a compound.
Alternatively, if you need a list, Term =.. [Name|Args]
.
You are absolutely right …
I didn’t know you can call arg/3 without instantiated index.
Dan