Hello, I'm using picolisp version 18.12.27 C in a debian 10.10 based distro, installed as package picolisp 18.12-1
I'm playing with pilog and there're some examples that does not run: 1- the example in doc reference for repeat/0 [1] : : (be integer (@I) # Generate unlimited supply of integers (^ @C (box 0)) # Init to zero (repeat) # Repeat from here (^ @I (inc @C)) ) -> integer : (? (integer @X)) @X=1 @X=2 @X=3 @X=4. # Stop -> NIL but I got nothing printed, no values for @X var, it keeps doing apparently nothing until I kill the process I can make it work if I use the -> functon this way: : (be integer (@I) (^ @C (box 0)) (repeat) (^ @I (inc (-> @C))) ) Is the reference documentation incorrect? 2- the example of factorial in Mia's blog [2] : : (be factorial (0 1) T) -> factorial : (be factorial (@N @X) (^ @A (dec @N)) (factorial @A @B) (^ @X (* @N @B)) ) -> factorial : (? (factorial 5 @X)) @X=120 -> NIL but when I execute (? (factorial 5 @X)) in my lisp I got: : (? (factorial 5 @X)) -> NIL only valid result is when executing (? (factorial 0 @X)) : : (? (factorial 0 @X)) @X=1 -> NIL debugging does not help: : (? factorial (factorial 0 @X)) 1 (factorial 0 1) @X=1 -> NIL : (? factorial (factorial 5 @X)) 2 (factorial 5 @X) -> NIL Again I get it working using the -> function this way: : (be factorial (@N @X) (^ @A (dec (-> @N))) (factorial @A @B) (^ @X (* (-> @N) (-> @B))) ) -> factorial Now: : (? (factorial 5 @X)) @X=120 -> NIL but I cannot get an answer for the inverse query: : (? (factorial @X 120)) -> NIL any hint? I assume the use of -> function is needed but that means picolisp documentation and Mia's blog is wrong. Also I would like to know if pilog unification deals with compound predicates, I mean, in prolog you can write: p(a). p(R(y)). ? p( X ) X=a X=R(y) Querying for values of X veryfing a p predicate. How can you get that in pilog? I've tried this two: (be p ((R y))) (be pp ((R (y)))) and it appears to work: (? (p @X)) @X=(R y) -> NIL (? (pp @X)) @X=(R (y)) -> NIL but I'm not sure it's the same semantics as prolog, because this appears to me as stating p as a list , not a compound predicate. In other words, what is the correct translation to this prolog clauses to pilog? prolog pilog p(a). (be p (a)) p(x,y). (be p (x y)) p(r(b)). (be p (r (b))) ? not working (-> NIL) (be p ((r (b)))) ? gets @X=(r (b)) (be p ((r b))) ? gets @X=(r b) p(z(a),b) (be p ((z a) b)) ? gets @X=(z a) @Y=b (be p ((z (a)) b)) ? gets @X=(z (a)) @Y=b best regards [1] R (software-lab.de) <https://software-lab.de/doc/refR.html#repeat/0> [2] How to use Pilog in PicoLisp (picolisp-explored.com) <https://picolisp-explored.com/how-to-use-pilog-in-picolisp>