Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Extraction...
Hi,

In my programm the user can call a function (I hope that's the correct term
in Prolog) "myFunction(X)". He will call this function by using the
parameter "fact(x)".
So the call looks like this: "myFunction(fact(x))".

Within "myFunction" I call another function "anotherFunction", like this:

myFunction(X) :- anotherFunction(X).

In this example both functions use the same parameter. When the User calls
"myFunction(fact(x))" then the parameter for "anotherFunction" is also
"fact(x)".

But to the "anotherFunction(X)" I want only assign the "x" from "fact(x)".
Thus I search for a possibility how I can extract the "x" out of "fact(x)".

Is that possible???

Greetings,

Manuel



Report this thread to moderator Post Follow-up to this message
Old Post
Manuel Winter
10-02-04 08:56 PM


Re: Extraction...
Manuel Winter schrieb:
> Hi,
>
> In my programm the user can call a function (I hope that's the correct ter
m
> in Prolog) "myFunction(X)". He will call this function by using the
> parameter "fact(x)".
> So the call looks like this: "myFunction(fact(x))".
>
> Within "myFunction" I call another function "anotherFunction", like this:
>
> myFunction(X) :- anotherFunction(X).
>
> In this example both functions use the same parameter. When the User calls
> "myFunction(fact(x))" then the parameter for "anotherFunction" is also
> "fact(x)".
>
> But to the "anotherFunction(X)" I want only assign the "x" from "fact(x)".
> Thus I search for a possibility how I can extract the "x" out of "fact(x)"
.
>
> Is that possible???
>
> Greetings,
>
> Manuel
>
>

well first, you don't have to forget that you just define predicates by
horn clauses. You don't have a function, you don't get a result from
"calling myFunction(X)".

for the other part, how to get x from fact(x), this is easy:
myFunction(fact(X)) :- anotherFunction(X).
pattern matching allows you to match against any named record.

--
Matthias

Report this thread to moderator Post Follow-up to this message
Old Post
Matthias Kretschmer
10-02-04 08:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Prolog archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:47 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.