Re: some questions relating pilog

2022-02-08 Thread Alexander Burger
Hi pd,

> I'm using picolisp version 18.12.27 C in a debian 10.10 based distro,
> ...
> I'm playing with pilog and there're some examples that does not run:
> ...
>(^ @I (inc @C)) )
> ...
> I can make it work if I use the -> functon this way:
> ...
>(^ @I (inc (-> @C))) )
> 
> Is the reference documentation incorrect?

No, but it seems that you looked at the reference for pil21.

The syntax for calling Lisp expressions in Pilog was made a little friendlier in
pil21, by binding variables directly, so that calling '->' is normally not
needed any more.


> 2- the example of factorial in Mia's blog  [2] :
> ...
> Again I get it working using the -> function this way:

Yes, exactly. So for pil64 and pil32 the old syntax is still required.

> I assume the use of -> function is needed but that means picolisp
> documentation and Mia's blog is wrong.

Not wrong, but it focuses exclusively on pil21.

> ...
> but I cannot get an answer for the inverse query:
> 
> : (? (factorial @X 120))
> -> NIL

This is another issue. This Pilog version of factorial cannot do reverse lookup,
as it calculate numeric values via Lisp calls.


> 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?

Yes, you can do that, but not in that direct syntax.

You could take a look at how 'not', 'call' or 'or' are implemented in
@lib/pilog.l for examples.

☺/ A!ex

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


Re: Wiki design update

2022-02-08 Thread Jean-Christophe Helary



> On Feb 9, 2022, at 12:12, Erik Gustafson  wrote:
> 
> Hi Jean-Christophe,
> 
> The  setting on line 247 is not inherited by  and that 
> cramps the code blocks inside the grey background box.
> 
> Oops! It seemed to be inherited in firefox for me. Ok, changed :) 

Erik,

There must be a lag because I am still seeing this in wiki.css:

(from l.239)

/* code highlighting */
code {
   color: #333;
   font-weight: bold;
   font-family: 'Courier New', monospace;
   background: #efefef;
   border-radius: 0.3rem;
   border: 1px solid #aaa;
   padding: 0 0.2rem;
   margin-right: 1px;
   overflow-x: auto;
   font-size: smaller;
}

pre.code {
   border-radius: 0.5rem;
   padding: unset;
   background: -webkit-gradient(linear, left top, right bottom, from(#efefef), 
color-stop(90%), to(#dfdfdf));
   background: -o-linear-gradient(top left, #efefef, 90%, #dfdfdf);
   background: linear-gradient(to bottom right, #efefef, 90%, #dfdfdf);
   -webkit-box-shadow: 1px 1px 1px 0px rgba(0,0,0,0.1);
   box-shadow: 1px 1px 1px 0px rgba(0,0,0,0.1);
}

Is it what you have ?

Jean-Christophe 


-- 
Jean-Christophe Helary @brandelune
https://mac4translators.blogspot.com
https://sr.ht/~brandelune/omegat-as-a-book/


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


Re: Wiki design update

2022-02-08 Thread Erik Gustafson
Hi Jean-Christophe,

The  setting on line 247 is not inherited by  and that
> cramps the code blocks inside the grey background box.
>

Oops! It seemed to be inherited in firefox for me. Ok, changed :)


Re: Wiki design update

2022-02-08 Thread Jean-Christophe Helary



> On Feb 9, 2022, at 10:20, Erik Gustafson  wrote:
> 
> Hi Jean-Christophe,
> 
> Good suggestions, that page looked pretty bad. I've uploaded a new css file 
> with the changes.

Erik,

Would you mind adding similar padding values to  as there are for 
 ?

The  setting on line 247 is not inherited by  and that cramps 
the code blocks inside the grey background box.

Jean-Christophe 

-- 
Jean-Christophe Helary @brandelune
https://mac4translators.blogspot.com
https://sr.ht/~brandelune/omegat-as-a-book/


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


some questions relating pilog

2022-02-08 Thread pd
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) 
[2] How to use Pilog in PicoLisp (picolisp-explored.com)



Re: Wiki design update

2022-02-08 Thread Erik Gustafson
Hi Jean-Christophe,

Good suggestions, that page looked pretty bad. I've uploaded a new css file
with the changes.

Thanks,
Erik


Re: Possible bug with prog1 and @

2022-02-08 Thread Alexander Burger
Hi Kevin,

> I may have encountered a possible bug, unless my understanding of @ is
> incorrect. It appears the value of @ is not restored in a prog1 body when
> another flow/logic statement occurs as the car of an expression within the

This is right. All flow functions which set '@' do *not* bind it. The value is
simply set.


> Test Cases:
> 
>   (let (A0 (1)
> A1 (2 3)
> A2 'x)
> (prog1 (cdr A1)

At this moment '@' is set to the result of evaluating (cdr A1).

>   ((if (sym? A2) 'set 'con) A2 A0)

Now '@' was overwritten by 'if'.


'@' is bound only on the function call level. That is, '@' is restored to the
caller's value when the function returns.

But inside a function's body the rule is that

1. Functions with controlling expressions just set '@' to the result. 'prog1' is
   such a function.

2. Functions with conditional expressions set '@' to the result *IF* the result
   is non-NIL (otherwise they leave it untouched).


All this is described in more detail in

   https://software-lab.de/doc/ref.html#atres

☺/ A!ex

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


Re: Possible bug with prog1 and @

2022-02-08 Thread Wilhelm Fitzpatrick

This behavior seems like it is "as advertised"? I see in the documentation:

"Flow- and logic-functions store the result of their controlling 
expression - respectively non-NIL results of their conditional 
expression - in @."


So the case when (sym? A2) seemingly would not update the current value 
of @, and...


"@ is generally local to functions and methods, its value is 
automatically saved upon function entry and restored at exit."


No function has been entered or exited here, unless I'm misunderstanding 
what constitutes a function.


-wilhelm

On 2/8/22 9:15 AM, Kevin Ednalino wrote:

Hello,

I may have encountered a possible bug, unless my understanding of @ is 
incorrect. It appears the value of @ is not restored in a prog1 body 
when another flow/logic statement occurs as the car of an expression 
within the said prog1 body. In both cases, the correct result is 
returned from prog1.


Test Cases:

  (let (A0 (1)
        A1 (2 3)
        A2 'x)
    (prog1 (cdr A1)
      ((if (sym? A2) 'set 'con) A2 A0)
      # Prints T when sym? result is T (incorrect)
      # but prints (3) when sym? result is NIL (correct)
      # Expect (3) printed regardless of sym? result
      (println @)))

  (let (A0 (1)
        A1 (2 3)
        A2 (4))
    (prog1 (cdr A1)
      ((if (sym? A2) 'set 'con) A2 A0)
      # Prints T when sym? result is T (incorrect)
      # but prints (3) when sym? result is NIL (correct)
      # Expect (3) printed regardless of sym? result
      (println @)))

Thanks,
Kevin

Possible bug with prog1 and @

2022-02-08 Thread Kevin Ednalino
Hello,

I may have encountered a possible bug, unless my understanding of @ is
incorrect. It appears the value of @ is not restored in a prog1 body when
another flow/logic statement occurs as the car of an expression within the
said prog1 body. In both cases, the correct result is returned from prog1.

Test Cases:

  (let (A0 (1)
A1 (2 3)
A2 'x)
(prog1 (cdr A1)
  ((if (sym? A2) 'set 'con) A2 A0)
  # Prints T when sym? result is T (incorrect)
  # but prints (3) when sym? result is NIL (correct)
  # Expect (3) printed regardless of sym? result
  (println @)))

  (let (A0 (1)
A1 (2 3)
A2 (4))
(prog1 (cdr A1)
  ((if (sym? A2) 'set 'con) A2 A0)
  # Prints T when sym? result is T (incorrect)
  # but prints (3) when sym? result is NIL (correct)
  # Expect (3) printed regardless of sym? result
  (println @)))

Thanks,
Kevin


Re: Wiki design update

2022-02-08 Thread Jean-Christophe Helary
Very nice Erik !

Regarding the border-radius for the  tag (currently at 0.3/0.5 for the 
), I think something a bit less curved would look better at the box angles:

https://picolisp.com/wiki/?help

Also, adding just a tiny bit of padding would make the code breath a bit.

Cheers,

Jean-Christophe 

> On Feb 8, 2022, at 22:47, Erik Gustafson  wrote:
> 
> Hi list,
> 
> I thought the wiki could use an update for 2022. Have a look - picolisp.com
> 
> There's a new take on the logo, the login/edit forms are nicer and better 
> behaved on mobile. And I threw in some CSS gradients to make it look extra 
> cool 
> 
> Feedback welcome!
> 
> -Erik

-- 
Jean-Christophe Helary @brandelune
https://mac4translators.blogspot.com
https://sr.ht/~brandelune/omegat-as-a-book/


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


Wiki design update

2022-02-08 Thread Erik Gustafson
Hi list,

I thought the wiki could use an update for 2022. Have a look - picolisp.com

There's a new take on the logo, the login/edit forms are nicer and better
behaved on mobile. And I threw in some CSS gradients to make it look extra
cool 

Feedback welcome!

-Erik