users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question on assert and retract--ground testing.


From: David Bennett
Subject: Re: question on assert and retract--ground testing.
Date: Tue, 27 Aug 2002 17:57:16 -0600

Lindsey,
You're right about the spurious final clause and cut... It is something that
I literally slapped together that met my needs quickly...Glad it was of
interest - thanks for the feedback.
-David
----- Original Message -----
From: <address@hidden>
To: "David Bennett" <address@hidden>
Cc: <address@hidden>; "bruno patin" <address@hidden>
Sent: Tuesday, August 27, 2002 2:32 PM
Subject: Re: question on assert and retract--ground testing.


> David,
> You piqued my interest, so I went to  my benchmark source and looked at
> the 'ground' implementations. The implementation you provided is very
> near what appears to be the fastest implementation among the four I have.
>
> Years ago (on Fri Feb 28 00:33:49 1992, to be precise), Richard A.
> O'Keefe posted an extensive note on 'ground' checking in the
> comp.lang.prolog newsgroup (as part of a discussion with David Bowen and
> Saumy K. Debray). I adopted RAOK's various forms of definition of ground
> as part of my 'benchmark' program.
>
> Of these various forms (there are four, using univ and functor/arg in
> different ways), the fastest one for gprolog 1.2.13 on my G4 Mac is
> currently:
>
> ground(Term) :-
>          (   atomic(Term) -> true
>          ;   nonvar(Term),
>              Term =.. [_|Args],
>              ground_args(Args)
>          ).
>
> ground_args([]).
> ground_args([H|T]) :-
>          ground(H),
>          ground_args(T).
>
> This one is two to three times faster than the functor/arg-based
> ground/1 programs. Go figure. (I'd expect functor/arg to be faster than
> univ.) As RAOK points out, it's important to measure actual performance,
> not just speculate. In the case of various ground/1 implementations,
> RAOK found that different implementations were the fastest on different
> systems.
>
> This one differs from David's is_ground/1 in that:
> is_ground/1 uses multiple clauses to test atom, number, and var, instead
> of a single clause using the builtin if-then-else in ground/1.
> There are no uses of cut in ground/1 or ground_args/1, and particularly
> is_ground_list/1 seems to have a spurious final clause and thus needless
> uses of cut .
>
> -lindsey
>
>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]