Re: (< @X 18) doesn't behave as expected with pilog

2016-11-12 Thread CILz

Hi Alexander,

Thanks for this answer. It works nicely. I will take my time to 
understand it thoroughly.


Best.


Le 12/11/2016 à 16:27, Alexander Burger a écrit :

Hi Eric,


(be underage (@X)
   (age @X @Y)
   (< @Y 18))

'<' is a Lisp function and not a Pilog rule. To embed a Lisp expression
in Pilog, you must use the '^' operator. It causes the rest of the
expression to be taken as Lisp, and inside the Lisp code you can in turn
access Pilog-bindings with the '->' function.

In the case above it should be something like

(^ @ (< (-> @Y) 18))

'@' is an anonymous variable here. If you want to bind the result of the
Lisp expression to a specific variable, it would be e.g.

(^ @X (+ (-> @N) 7))

This binds @X to @N + 7.


Of course, if you need '<' more often, you could define your own
predicate:

: (be < (@A @B)
   (^ @ (< (-> @A) (-> @B))) )
-> <

: (? (< 3 4))
-> T

: (? (< 4 2))
-> NIL

♪♫ Alex


--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Unsubscribe

2016-11-12 Thread Kyle
Good bye Kyle  :-(
You are now unsubscribed


--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (< @X 18) doesn't behave as expected with pilog

2016-11-12 Thread CILz
Thanks for this Joe. However I will need to investigate as I don't know 
Picolisp enough yet. My purpose is first to translate Prolog queries to 
Pilog in a Prologish/Pilogish way.



Le 12/11/2016 à 16:23, Joe Bogner a écrit :

Untested, but what about using range/3 ?
http://software-lab.de/doc/refR.html#range/3


--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (< @X 18) doesn't behave as expected with pilog

2016-11-12 Thread Alexander Burger
Hi Joe,

> Untested, but what about using range/3 ?
> http://software-lab.de/doc/refR.html#range/3

Thanks! However, range/3 is probably not useful here. It is a rather
specialized predicate for range checks in database queries.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (< @X 18) doesn't behave as expected with pilog

2016-11-12 Thread Alexander Burger
Hi Eric,

> (be underage (@X)
>   (age @X @Y)
>   (< @Y 18))

'<' is a Lisp function and not a Pilog rule. To embed a Lisp expression
in Pilog, you must use the '^' operator. It causes the rest of the
expression to be taken as Lisp, and inside the Lisp code you can in turn
access Pilog-bindings with the '->' function.

In the case above it should be something like

   (^ @ (< (-> @Y) 18))

'@' is an anonymous variable here. If you want to bind the result of the
Lisp expression to a specific variable, it would be e.g.

   (^ @X (+ (-> @N) 7))

This binds @X to @N + 7.


Of course, if you need '<' more often, you could define your own
predicate:

   : (be < (@A @B)
  (^ @ (< (-> @A) (-> @B))) )
   -> <

   : (? (< 3 4))
   -> T

   : (? (< 4 2))
   -> NIL

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (< @X 18) doesn't behave as expected with pilog

2016-11-12 Thread Joe Bogner
Untested, but what about using range/3 ?
http://software-lab.de/doc/refR.html#range/3



On Sat, Nov 12, 2016 at 9:59 AM, CILz  wrote:
> Hello,
>
> Let's say that I have those two facts in a pilog database:
>
> (be age (Paul 18))
> (be age (Vincent 17))
>
> I'm looking for the guy under 18 with this rule:
>
> (be underage (@X)
>   (age @X @Y)
>   (< @Y 18))
>
> If I ask (? (underage @X)) the result here is -> NIL where I expect to get
> @X=Vincent.
>
> If I modify the above rule with:
>
> (be underage (@X)
>   (age @X @Y)
>   (equal @Y 18))
>
> The same query (? (underage @X)) now gives @X=Paul which is the expected
> result.
>
> I'm sure I'm missing something in the first case but I don't know what. Any
> idea?
>
> Thanks,
>
> Eric
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: First post

2016-11-12 Thread Joe Bogner
Hello Eric! Thanks for the introduction. Welcome! Looking forward to
your questions!

On Sat, Nov 12, 2016 at 9:45 AM, CILz  wrote:
> Dear list,
>
> I take the opportunity of this first post to introduce myself as well as the
> reasons for which I come here.
>
> I am not a computer scientist nor a professional web developper but a kind
> of "power user" who often gets its hands dirty to build some applications as
> close as possible to what he wants... That being said, I have mostly built
> some websites using off the shelf CMS ;-)
>
> However, my last "product" is a custom web application fully written from
> scratch in R to access a graph database. And this is why I am here: I want
> to rebuild it in order to add some "expert system" like capacity...
>
> So starting to digg around, I first came to Prolog a few weeks ago and I
> started learning it from scratch. This very week, I discovered Picolisp. I
> started exploring it, and so far, I am really impressed! It looks very
> appealing: having at hand a powerful language, a built-in database system as
> well as Prolog make me dream ... though I don't know if I am skilled enough
> to be able to do anything useful!
>
> Any way, I have it up an running on my linux box ... so expect me to ask
> very basic questions soon :)
>
> Best,
>
> Eric
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: First post

2016-11-12 Thread Alexander Burger
Hi Eric,

> Any way, I have it up an running on my linux box ... so expect me to ask
> very basic questions soon :)

Welcome! Please let us know how we can help.

As beneroth wrote in another mail today, it might be also a good idea to
visit the #picolisp IRC channel at freenode.net :)

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


(< @X 18) doesn't behave as expected with pilog

2016-11-12 Thread CILz

Hello,

Let's say that I have those two facts in a pilog database:

(be age (Paul 18))
(be age (Vincent 17))

I'm looking for the guy under 18 with this rule:

(be underage (@X)
  (age @X @Y)
  (< @Y 18))

If I ask (? (underage @X)) the result here is -> NIL where I expect to 
get @X=Vincent.


If I modify the above rule with:

(be underage (@X)
  (age @X @Y)
  (equal @Y 18))

The same query (? (underage @X)) now gives @X=Paul which is the expected 
result.


I'm sure I'm missing something in the first case but I don't know what. 
Any idea?


Thanks,

Eric

--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


First post

2016-11-12 Thread CILz

Dear list,

I take the opportunity of this first post to introduce myself as well as 
the reasons for which I come here.


I am not a computer scientist nor a professional web developper but a 
kind of "power user" who often gets its hands dirty to build some 
applications as close as possible to what he wants... That being said, I 
have mostly built some websites using off the shelf CMS ;-)


However, my last "product" is a custom web application fully written 
from scratch in R to access a graph database. And this is why I am here: 
I want to rebuild it in order to add some "expert system" like capacity...


So starting to digg around, I first came to Prolog a few weeks ago and I 
started learning it from scratch. This very week, I discovered Picolisp. 
I started exploring it, and so far, I am really impressed! It looks very 
appealing: having at hand a powerful language, a built-in database 
system as well as Prolog make me dream ... though I don't know if I am 
skilled enough to be able to do anything useful!


Any way, I have it up an running on my linux box ... so expect me to ask 
very basic questions soon :)


Best,

Eric

--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: The behaviour of arg

2016-11-12 Thread Henrik Sarvell
In this case I simply use (arg 1), I just wanted to check if perhaps
(arg) defaulted to (arg 1) if no prior next had been called.

On Sat, Nov 12, 2016 at 7:45 AM, Alexander Burger  wrote:
> Hi Henrik, Andreas,
>
>> I guess this is the unforgiving punishment for calling (arg) without
>> calling (next) previously, consider the reference:
>> "If cnt is not given, the value that was returned from the last call
>> to next" -> no previous call to next -> invalid usage -> punishment
>
> Exactly! In fact, 'arg' should check such illegal usage. It is a
> secondary function, and not much used.
>
>
> The main workhorse for variable arguments is 'next', and often
> all that is needed:
>
>: (de f @
>   (while (next)
>  (println @) ) )
>
>-> f
>:  (f 1 2 3)
>1
>2
>3
>
> The purpose of 'arg' is to avoid the overhead of a local variable if
> the value is used more than once.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe