Subject: [SWIPL] Some beginers questions

From: "raptor" <[email-masked]>
Date: Tue, 6 Mar 2001 11:59:05 -0000

hi,

Could U help to one beginer.. sorry if the questions are very stupid, I'm
still two-day PROLOG programmer :").
And here they are :

1. Does SWI-prolog support RegEx, I didn't found anything in the Docs. If
not, is there i way to use them !?!
2. How can I tokenize text .. example.
3. Is there a way to set a VAR, what i have in mind. F.e. I need to make
some tests with
lists and want to say something like this :

MyList = [1,4,56,dd,66].

so not to write this every time but pass it like argument to list functions
i.e. :

?- liststuff(Result,MyList).

4. Where I can find more info about DCG grammar rules, of cource with more
examples as for the beginer.

5. What is the difference between call(p) & normal invoking of rule ?! I
can't figure out :"(

6. Is there something like EVAL in Perl. What I mean ? F.e.:

expr(Str) :- eval(Str).

expr("35 > 12").

OR better.

expr(X,C,Y):- eval([X,C,Y]).  OR  expr(List):- eval(List).

expr(34, > , 78)   OR expr([34, > , 78])

I mean that all these expressions will be created on the fly.
Currently I'm using something like this, don't laught :")

cond_type(X,'>',Y) :- X > Y.
cond_type(X,'<',Y) :- X < Y.
cond_type(X,'=',Y) :- X = Y.

cond([X,C,Y]) :- integer(X),integer(Y),cond_type(X,C,Y),writef("Condition %w
%w %w met\n",[ X,C,Y]).

7. Is there a way to ALIAS some function.(not so important) f.e.:

alias(pop,last).

?- pop(Elem,[3,5,6,7,8]).

Elem = 8

8. How to print LIST on the screen ?!

9. After alot of experiments, I've got this solution for capturing content
of (),[],..etc..

next(Res,[H|_]) :- H == ")", Res = [].
next(Res,[H|T]) :-  next(Res2, T), Res = [ H | Res2 ].
braces(Res,[H|T]) :- H == "(", next(Res,T).

?- braces(Res,["(",f,g,4,3,")",d,f,g]).

Res = [f,g,4,3]

Is this the correct way ?! I still didn't tried parsing this ((...(..))) !!

U may see that the most of the questions are related to PARSING, this is
coinsidence.
I just can't figured out from where to begin.. 'cause I can't connect all
these

likes(mari,stefan).
likes(mari,peter).
?- likes(mari,X).

with some real problem yet :")

Thanx alot in advance for the help.

=====
iVAN
[email-masked]
=====