Re: How to return clause in findall/3
From: Pere Montolio (tmp123_at_menta.net)
Date: 08/12/04
- Previous message: Sangai: "Re: Help I'm stuck!"
- In reply to: rhapsody: "How to return clause in findall/3"
- Next in thread: rhapsody: "Re: How to return clause in findall/3"
- Reply: rhapsody: "Re: How to return clause in findall/3"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 12 Aug 2004 00:21:32 -0700
"rhapsody" <blurrynight@yahoo.com> wrote in message news:<f12b89feca33ea7c0cce07b2be4719cf@localhost.talkaboutprogramming.com>...
> Hi, I am new to Prolog. What is the correct way of returning a list of
> clauses 'sc/3' to the variable X? Below is my codes:
> Database
> sc(symbol Sid,symbol Cid, integer ExamScore).
>
> Clauses
> sc("S1","C1",55).
> sc("S1","C2",60).
> sc("S1","C3",70).
> Goal
> findall(sc(),sc(X,_,_),List), X="S1", write(List), nl.
>
> Thanks in advance!
> Stanly
It is posible one of the following rules was useful for your objectives:
findall([A,B,C],sc(A,B,C),List).
or
findall([B,C],sc("S1",B,C),List).
- Previous message: Sangai: "Re: Help I'm stuck!"
- In reply to: rhapsody: "How to return clause in findall/3"
- Next in thread: rhapsody: "Re: How to return clause in findall/3"
- Reply: rhapsody: "Re: How to return clause in findall/3"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|