Re: problem with anonymous variables
- From: "Brian Hulley" <brianh@xxxxxxxxxxxx>
- Date: 27 May 2005 13:38:12 -0700
ouyang.jie@xxxxxxxxx wrote:
> an anonymous variable is representated by an underscore "_". for
> instance , f(_,A,_) has 2 anonymous variables. given a list [_,A,B,_],
> i want to have the list [A,B] returned or 2 as the number of
> non-anonymous variables returned. any idea?
As far as Prolog terms are concerned there is no difference between
[_,A,B,_] and [X,Y,Z,W] since in all cases you have 4 variables all
distinct from each other.
Ie the anonymous variable is a convenience only (so you don't have to
think up names for variables you don't care about and so that you can
get the singleton-variable warning when a non-anonymous variable is
only used once), and although implementations can make use of the fact
that an anonymous variable has been used to improve performance, the
language itself has no way to distinguish an anonymous variable from
any other variable.
.
- References:
- problem with anonymous variables
- From: ouyang . jie
- Re: problem with anonymous variables
- From: Bart Demoen
- Re: problem with anonymous variables
- From: ouyang . jie
- problem with anonymous variables
- Prev by Date: Re: Prolog -> Tex
- Next by Date: Re: Prolog [book] for beginners.
- Previous by thread: Re: problem with anonymous variables
- Next by thread: Re: problem with anonymous variables
- Index(es):