Succeeding and failing

18 views
Skip to first unread message

Jeff Andersen

unread,
Nov 29, 2012, 8:18:44 PM11/29/12
to byu-cs-330...@googlegroups.com
Basic question here, but I feel a bit lost.

=succeed returns a prolog-expression that succeeds once and then, I presume, repeatedly fails.
=fail returns a prolog-expression that always fails.

What exactly constitutes a failure or success?  I just have mine printing out "success" or "failure".

Jeff Andersen

unread,
Nov 29, 2012, 8:38:23 PM11/29/12
to byu-cs-330...@googlegroups.com
Whoops, looks like these two don't return expressions, they are expressions.  My bad.  But my question still stands; what should constitute a failure or success?

Jay McCarthy

unread,
Nov 29, 2012, 8:55:33 PM11/29/12
to BYU CS 330 Fall 2012
At a most basic level, an expression fails by calling its failure
continuation (the one it received as an argument) and succeeds by
returning a success continuation. This is all described in the
introductory paragraphs of the assignment.

Jay
> --
>
>



--
Jay McCarthy <j...@cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

Andrew

unread,
Dec 1, 2012, 2:25:25 PM12/1/12
to byu-cs-330...@googlegroups.com
As I'm trying to begin this assignment I'm having a difficult time decomposing some of the statements in the intro paragraphs of the prolog assignment.
 
I'm trying to get a grasp on =succeed and =fail.
 
Okay, so =succeed and =fail are prolog-expressions, which is a function of the form:
failure-continuation -> success-continuation.
 
The success continuation they return is:
some_arg -> [void OR success-continuation]
 
And the failure function they take as an argument is of the form:
some_arg -> [fail OR success-continuation]
 
So I tried to just write a generic failure-continuation:
(define fk (λ (x) 'fail)
it takes something it ignores and in this case just fails.
 
And I thought I'd try it out with the =succeed and =fail prolog-expressions.
So for the following:
 
(=succeed fk) ;L1
((=succeed fk) "done") ;L2
(=fail fk) ;L3
 
My thoughts on what these statements should do was:
 
L1 should return a procedure (a success-continuation).
 
L2 should not return anything (it is calling the success-continuation returned on L1 that should "succeed only once").
 
L3 should call the failure continuation, fk, and in this case it prints out the symbol 'fail.
 
Is that anywhere close to correct?
 
Thanks,
Andrew

Jay McCarthy

unread,
Dec 1, 2012, 2:40:47 PM12/1/12
to BYU CS 330 Fall 2012
In this case, since you aren't just asking for clarification, but are
asking about if your own assignment efforts are on the right track...
Please don't send emails like this to the list.

Andrew

unread,
Dec 1, 2012, 3:38:45 PM12/1/12
to byu-cs-330...@googlegroups.com
I apologize - I was trying to be generic in my asking/phrasing.
 
Thanks!

Jay McCarthy

unread,
Dec 1, 2012, 3:42:48 PM12/1/12
to BYU CS 330 Fall 2012
It's not that big of a problem, so don't worry about it.
Reply all
Reply to author
Forward
0 new messages