Re: [CS3304_1381] Help with cut

New Message Reply About this list Date view Thread view Subject view Author view

Mark Hinkle (mhinkle@VT.EDU)
Tue, 25 Apr 2000 02:04:40 -0400


Message-ID:  <Pine.LNX.4.21.0004250152270.2423-100000@localhost.localdomain>
Date:         Tue, 25 Apr 2000 02:04:40 -0400
From: Mark Hinkle <mhinkle@VT.EDU>
Subject:      Re: [CS3304_1381] Help with cut

On Tue, 25 Apr 2000, Nathan Conklin wrote:

> >
> > How can I slim down the answers I get returned from a predicate to 1? For
> > example, term([2,times,3,times,4],N). returns all of
> > N = [24|1] ;
> > N = [[24|1], 1] ;
> > N = [[24|1], []] ;
> > N = [6|1] ;
> > N = [[6|1], 1] ;
> > N = [[6|1], [times, 4]] ;
> > N = [2|1] ;
> > N = [[2|1], [times, 3, times, 4]] ;
> >
> > I just want the first answer. I'm pretty sure I need to use cut(!) but
> > the all documentation I've been able to find on its use is pretty
> > slim. Has anyone used it successfully, and could you please post a crash
> > course on it?
> >
>
> Using cut will probably not be want you want in most cases. This is
> because you want the backtracking mechanism of Prolog to help out. What I
> suggest doing is implementing your OR conditions similar to:
>
> if(cond)
> pred1;
> else
> pred2;
>
> (cond,pred1);
> (not(cond),pred2).
>
> I have found this to help so that a predicate returns only one value.
> Then, you will need to find each the predicates that you can apply this to.
>

*or*?? I totally forgot about or'ing statements. I stumbled upon how to
use the cuts just by trial & error. I'd say my program is 95% done and I
dont have a single or.. teehee. and my code is very readable
too... guess im just doing it the alternative way.

i guess i could slim down my code a little with some if then else's, but
that depends on how tired i get.

Any tips/hints on writing the report? That still seems to be where I lose
all my points... even after having done it 3 times before. It has gotten
quite frustrating... i thought this was a class where we learned different
languages, not where we were graded on how well we can write a report.
That's what our technical writing class was for. OK.. sorry. Had to blow
a little steam there. I dont mean to bitch. Some tips would still be
helpful. Anyone?

Thanks for all your help Nathan.

Mark


New Message Reply About this list Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b3 on Tue Apr 25 2000 - 02:02:07 EDT