How to display some text in Pilog

2016-11-22 Thread CILz

Hello,

I'm trying to translate a small Prolog programme into Pilog however I'm 
stuck on some basic things. For example, how would you translate this 
Prolog term:


intro :-

write("somme text ...").


which yields to (in Swi-Prolog):

?. intro.

somme text ...

true.


Best,

Eric

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


Re: help with val

2016-11-22 Thread dean
Hi Alexander
>Perhaps it helps to see it this way:
Yes it helps a lot and thank you very much for taking the trouble to
clarify things.
Best Regards
Dean




On 22 November 2016 at 20:52, Alexander Burger  wrote:

> On Tue, Nov 22, 2016 at 09:22:14PM +0100, Alexander Burger wrote:
> > > "The CDR of a symbol cell is also called VAL, and the CAR points to the
> > > symbol's tail. "
> >  ...
> > Yes, but note that this talks about the symbol's *cell*, i.e. the
> > internal representation as described in doc64/structures.
> > ...
> > On the language level, a symbol only has a value, properties and a name

Re: help with val

2016-11-22 Thread Alexander Burger
On Tue, Nov 22, 2016 at 09:22:14PM +0100, Alexander Burger wrote:
> > "The CDR of a symbol cell is also called VAL, and the CAR points to the
> > symbol's tail. "
>  ...
> Yes, but note that this talks about the symbol's *cell*, i.e. the
> internal representation as described in doc64/structures.
> ...
> On the language level, a symbol only has a value, properties and a name.
> No CDR :)

Perhaps it helps to see it this way:

1. CAR and CDR (in upper case) are the two halves of a cell

  +-+-+
  | CAR | CDR |
  +-+-+

   no matter whether this cell represents a number, a symbol or a list.


2. 'car' and 'cdr' (in lower case) are the functions to access the
   elements of pairs and lists.

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


Re: help with val

2016-11-22 Thread Alexander Burger
Hi Dean,

> from ref.html
> "The CDR of a symbol cell is also called VAL, and the CAR points to the
> symbol's tail. "

Yes, but note that this talks about the symbol's *cell*, i.e. the
internal representation as described in doc64/structures.

> but val seems to equate to car from my tests so I'm confused
> : (set 'x 3)
> -> 3
> : (car 'x)
> -> 3
> : (val 'x)
> -> 3
> : (cdr 'x)
> !? (cdr 'x)
> x -- List expected

On the language level, a symbol only has a value, properties and a name.
No CDR :)

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


help with val

2016-11-22 Thread dean
from ref.html
"The CDR of a symbol cell is also called VAL, and the CAR points to the
symbol's tail. "

but val seems to equate to car from my tests so I'm confused
: (set 'x 3)
-> 3
: (car 'x)
-> 3
: (val 'x)
-> 3
: (cdr 'x)
!? (cdr 'x)
x -- List expected


Re: stuck re quote

2016-11-22 Thread dean
Thank you very much Cristophe


On 22 November 2016 at 13:03, Christophe Gragnic <
christophegrag...@gmail.com> wrote:

> On Tue, Nov 22, 2016 at 11:29 AM, dean  wrote:
> >
> > Also I read that ' is a macro for quote but I couldn't produce a '
> > equivalent of ((quote (X) (* X X)) 9) i.e.
> >
> > : ((quote (X) (* X X)) 9)
> > -> 81
> > : (('(X) (* X X)) 9)
> > !? (('(X) (* X X)) 9)
> > NIL -- Undefined
> > ?
> > : (('X (* X X)) 9)
> > !? ('X (* X X))
> > X -- Undefined
>
> Your quote is misplaced. It should be:
> ('((X) (* X X)) 9)
>
>
> chri
>
> --
>
> http://profgra.org/lycee/ (site pro)
> http://delicious.com/profgraorg (liens, favoris)
> https://twitter.com/profgraorg
> http://microalg.info (langage de programmation pédagogique)
> http://expressions.club/ (structure des expressions mathématiques)
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Re: stuck re quote

2016-11-22 Thread dean
I just came back to say this...
http://picolisp.com/wiki/?articlequote
looks very helpful
but see your very comprehensive reply.
I'll have a good look through both of them.
Thank you very much Joe.

On 22 November 2016 at 12:51, Joe Bogner  wrote:

> On Tue, Nov 22, 2016 at 5:29 AM, dean  wrote:
> >
> > Joe
> > My question came from that very documentation so I'm well aware of it.
> >
> > I've never used a lambda but your Javascipt example helps a lot and
> suggests
> > that 'quote' in
> >
> >
> > ((quote (X) (* X X)) 9)
> >
> >
> > transforms the statement into something like
> >
> > (
> >   (de anon (X)
> > (* X X)
> >   )
> >   anon 9
> > )
> >
> > If that's right..great but the transformation isn't intuitive to me at
> > all i.e. I thought quote just stopped the evaluation of a symbol.
> > It looks like it's doing a lot more than that here.
>
> It's not a literal transformation. The phrasing is used to help the
> reader understand the execution of the statement. The statement is not
> transformed and can still be inspected
>
> : (setq f1 (quote (X) (* X X)))
> -> ((X) (* X X))
> : (f1 9)
> -> 81
>
> : (car f1)
> -> (X)
> : (cdr f1)
> -> ((* X X))
>
>
> This is the same as
>
> : (setq f2 '((X) (* X X)))
> -> ((X) (* X X))
> : (f2 9)
> -> 81
>
> or
>
> : ('((X) (* X X)) 9)
> -> 81
>
>
> The statements are equivalent
>
> : (= f1 f2)
> -> T
>
>
>
>
> >
> > Also I read that ' is a macro for quote but I couldn't produce a '
> > equivalent of ((quote (X) (* X X)) 9) i.e.
> >
>
> See above
>
> I suggest reading through the 'Evaluation' section of
> http://software-lab.de/doc/ref.html. I've read it several times over
> the years. I probably read the reference 3 times before it really
> stuck. Often it needs to be re-read as new concepts that have been
> learned make it more clear.
>
> I'll paste some relevant sections that I think help explain the concept..
>
> In the example above, f1 is a list, whose CAR is a is a list of symbols
>
> : (car f1)
> -> (X)
>
>
>
> -- start paste
>
> Otherwise, if the CAR is a symbol or a list, PicoLisp tries to obtain
> an executable function from that, by either using the symbol's value,
> or by evaluating the list.
>
> What is an executable function? Or, said in another way, what can be
> applied to a list of arguments, to result in a function call? A legal
> function in PicoLisp is
>
> ..
>
> or
> a lambda expression. A lambda expression is a list, whose CAR is
> either a symbol or a list of symbols, and whose CDR is a list of
> expressions. Note: In contrast to other Lisp implementations, the
> symbol LAMBDA itself does not exist in PicoLisp but is implied from
> context.
>
>
> .
>
> -- end paste
>
> Based on the above, we can also write the expression as
>
> ('(X (* 9 9)) 9)
>
> : (setq f3 '(X (* 9 9)))
> -> (X (* 9 9))
> : (f3 9)
> -> 81
>
> The statements aren't the same
>
> : (= f3 f2)
> -> NIL
>
> But the interpreter will execute them the same since the CAR of the
> list is a symbol (not a list of symbols as-is f2). A list of symbols
> is more common to see
>
> : (car f3)
> -> X
>
> Hope this helps. The key here is realizing that quote/' doesn't
> literally transform to a de, it just evaluates as if it did
>
> Joe
>
> On Tue, Nov 22, 2016 at 5:29 AM, dean  wrote:
> >
> > Joe
> > My question came from that very documentation so I'm well aware of it.
> >
> > I've never used a lambda but your Javascipt example helps a lot and
> suggests
> > that 'quote' in
> >
> >
> > ((quote (X) (* X X)) 9)
> >
> >
> > transforms the statement into something like
> >
> > (
> >   (de anon (X)
> > (* X X)
> >   )
> >   anon 9
> > )
> >
> > If that's right..great but the transformation isn't intuitive to me at
> > all i.e. I thought quote just stopped the evaluation of a symbol.
> > It looks like it's doing a lot more than that here.
> >
> > Also I read that ' is a macro for quote but I couldn't produce a '
> > equivalent of ((quote (X) (* X X)) 9) i.e.
> >
> > : ((quote (X) (* X X)) 9)
> > -> 81
> > : (('(X) (* X X)) 9)
> > !? (('(X) (* X X)) 9)
> > NIL -- Undefined
> > ?
> > : (('X (* X X)) 9)
> > !? ('X (* X X))
> > X -- Undefined
> >
> >
> > Best Regards
> > Dean
> >
> > On 22 November 2016 at 04:16, Joe Bogner  wrote:
> >>
> >> Hi dean,
> >>
> >> It's not clear what you're asking. Does this help explain it?
> >>
> >> http://software-lab.de/doc/tut.html
> >>
> >> --- from the page ---
> >>
> >> Anonymous functions without the lambda keyword
> >>
> >> There's no distinction between code and data in PicoLisp, quote will
> >> do what you want (see also this FAQ entry).
> >>
> >> : ((quote (X) (* X X)) 9)
> >> -> 81
> >>
> >> : (setq f '((X) (* X X)))  # This is equivalent to (de f (X) (* X X))
> >> -> ((X) (* X X))
> >> : f
> >> -> ((X) (* X X))
> >> : (f 3)
> >> -> 9
> >>
> >> --- end from the page ---
> >>
> >> And http://software-lab.de/doc/ref.html
> >>
> >> "The most prominent 

Re: stuck re quote

2016-11-22 Thread Christophe Gragnic
On Tue, Nov 22, 2016 at 11:29 AM, dean  wrote:
>
> Also I read that ' is a macro for quote but I couldn't produce a '
> equivalent of ((quote (X) (* X X)) 9) i.e.
>
> : ((quote (X) (* X X)) 9)
> -> 81
> : (('(X) (* X X)) 9)
> !? (('(X) (* X X)) 9)
> NIL -- Undefined
> ?
> : (('X (* X X)) 9)
> !? ('X (* X X))
> X -- Undefined

Your quote is misplaced. It should be:
('((X) (* X X)) 9)


chri

-- 

http://profgra.org/lycee/ (site pro)
http://delicious.com/profgraorg (liens, favoris)
https://twitter.com/profgraorg
http://microalg.info (langage de programmation pédagogique)
http://expressions.club/ (structure des expressions mathématiques)
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: stuck re quote

2016-11-22 Thread Joe Bogner
On Tue, Nov 22, 2016 at 5:29 AM, dean  wrote:
>
> Joe
> My question came from that very documentation so I'm well aware of it.
>
> I've never used a lambda but your Javascipt example helps a lot and suggests
> that 'quote' in
>
>
> ((quote (X) (* X X)) 9)
>
>
> transforms the statement into something like
>
> (
>   (de anon (X)
> (* X X)
>   )
>   anon 9
> )
>
> If that's right..great but the transformation isn't intuitive to me at
> all i.e. I thought quote just stopped the evaluation of a symbol.
> It looks like it's doing a lot more than that here.

It's not a literal transformation. The phrasing is used to help the
reader understand the execution of the statement. The statement is not
transformed and can still be inspected

: (setq f1 (quote (X) (* X X)))
-> ((X) (* X X))
: (f1 9)
-> 81

: (car f1)
-> (X)
: (cdr f1)
-> ((* X X))


This is the same as

: (setq f2 '((X) (* X X)))
-> ((X) (* X X))
: (f2 9)
-> 81

or

: ('((X) (* X X)) 9)
-> 81


The statements are equivalent

: (= f1 f2)
-> T




>
> Also I read that ' is a macro for quote but I couldn't produce a '
> equivalent of ((quote (X) (* X X)) 9) i.e.
>

See above

I suggest reading through the 'Evaluation' section of
http://software-lab.de/doc/ref.html. I've read it several times over
the years. I probably read the reference 3 times before it really
stuck. Often it needs to be re-read as new concepts that have been
learned make it more clear.

I'll paste some relevant sections that I think help explain the concept..

In the example above, f1 is a list, whose CAR is a is a list of symbols

: (car f1)
-> (X)



-- start paste

Otherwise, if the CAR is a symbol or a list, PicoLisp tries to obtain
an executable function from that, by either using the symbol's value,
or by evaluating the list.

What is an executable function? Or, said in another way, what can be
applied to a list of arguments, to result in a function call? A legal
function in PicoLisp is

..

or
a lambda expression. A lambda expression is a list, whose CAR is
either a symbol or a list of symbols, and whose CDR is a list of
expressions. Note: In contrast to other Lisp implementations, the
symbol LAMBDA itself does not exist in PicoLisp but is implied from
context.


.

-- end paste

Based on the above, we can also write the expression as

('(X (* 9 9)) 9)

: (setq f3 '(X (* 9 9)))
-> (X (* 9 9))
: (f3 9)
-> 81

The statements aren't the same

: (= f3 f2)
-> NIL

But the interpreter will execute them the same since the CAR of the
list is a symbol (not a list of symbols as-is f2). A list of symbols
is more common to see

: (car f3)
-> X

Hope this helps. The key here is realizing that quote/' doesn't
literally transform to a de, it just evaluates as if it did

Joe

On Tue, Nov 22, 2016 at 5:29 AM, dean  wrote:
>
> Joe
> My question came from that very documentation so I'm well aware of it.
>
> I've never used a lambda but your Javascipt example helps a lot and suggests
> that 'quote' in
>
>
> ((quote (X) (* X X)) 9)
>
>
> transforms the statement into something like
>
> (
>   (de anon (X)
> (* X X)
>   )
>   anon 9
> )
>
> If that's right..great but the transformation isn't intuitive to me at
> all i.e. I thought quote just stopped the evaluation of a symbol.
> It looks like it's doing a lot more than that here.
>
> Also I read that ' is a macro for quote but I couldn't produce a '
> equivalent of ((quote (X) (* X X)) 9) i.e.
>
> : ((quote (X) (* X X)) 9)
> -> 81
> : (('(X) (* X X)) 9)
> !? (('(X) (* X X)) 9)
> NIL -- Undefined
> ?
> : (('X (* X X)) 9)
> !? ('X (* X X))
> X -- Undefined
>
>
> Best Regards
> Dean
>
> On 22 November 2016 at 04:16, Joe Bogner  wrote:
>>
>> Hi dean,
>>
>> It's not clear what you're asking. Does this help explain it?
>>
>> http://software-lab.de/doc/tut.html
>>
>> --- from the page ---
>>
>> Anonymous functions without the lambda keyword
>>
>> There's no distinction between code and data in PicoLisp, quote will
>> do what you want (see also this FAQ entry).
>>
>> : ((quote (X) (* X X)) 9)
>> -> 81
>>
>> : (setq f '((X) (* X X)))  # This is equivalent to (de f (X) (* X X))
>> -> ((X) (* X X))
>> : f
>> -> ((X) (* X X))
>> : (f 3)
>> -> 9
>>
>> --- end from the page ---
>>
>> And http://software-lab.de/doc/ref.html
>>
>> "The most prominent read-macro in Lisp is the single quote character
>> "'", which expands to a call of the quote function. Note that the
>> single quote character is also printed instead of the full function
>> name."
>>
>> ---
>>
>> In other words, quote is allowing you to define an anonymous function
>> equivalent to (function(x) { return x*x })(9) (in javascript for
>> example)
>>
>> On Mon, Nov 21, 2016 at 3:37 PM, dean  wrote:
>> > I could do with some help understanding step by step what's happening
>> > here...
>> >
>> > Intuitively I can see that 9 squared is 81 but I can't really see,
>> > precisely, what this was doing
>> >
>> 

Re: stuck re quote

2016-11-22 Thread dean
Joe
My question came from that very documentation so I'm well aware of it.

I've never used a lambda but your Javascipt example helps a lot and
suggests that 'quote' in


((quote (X) (* X X)) 9)


transforms the statement into something like

(
  (de anon (X)
(* X X)
  )
  anon 9
)

If that's right..great but the transformation isn't intuitive to me at
all i.e. I thought quote just stopped the evaluation of a symbol.
It looks like it's doing a lot more than that here.

Also I read that ' is a macro for quote but I couldn't produce a '
equivalent of ((quote (X) (* X X)) 9) i.e.

: ((quote (X) (* X X)) 9)
-> 81
: (('(X) (* X X)) 9)
!? (('(X) (* X X)) 9)
NIL -- Undefined
?
: (('X (* X X)) 9)
!? ('X (* X X))
X -- Undefined


Best Regards
Dean

On 22 November 2016 at 04:16, Joe Bogner  wrote:

> Hi dean,
>
> It's not clear what you're asking. Does this help explain it?
>
> http://software-lab.de/doc/tut.html
>
> --- from the page ---
>
> Anonymous functions without the lambda keyword
>
> There's no distinction between code and data in PicoLisp, quote will
> do what you want (see also this FAQ entry).
>
> : ((quote (X) (* X X)) 9)
> -> 81
>
> : (setq f '((X) (* X X)))  # This is equivalent to (de f (X) (* X X))
> -> ((X) (* X X))
> : f
> -> ((X) (* X X))
> : (f 3)
> -> 9
>
> --- end from the page ---
>
> And http://software-lab.de/doc/ref.html
>
> "The most prominent read-macro in Lisp is the single quote character
> "'", which expands to a call of the quote function. Note that the
> single quote character is also printed instead of the full function
> name."
>
> ---
>
> In other words, quote is allowing you to define an anonymous function
> equivalent to (function(x) { return x*x })(9) (in javascript for
> example)
>
> On Mon, Nov 21, 2016 at 3:37 PM, dean  wrote:
> > I could do with some help understanding step by step what's happening
> > here...
> >
> > Intuitively I can see that 9 squared is 81 but I can't really see,
> > precisely, what this was doing
> >
> > ((quote (X) (* X X)) 9)
> > -> 81
> >
> > so I put it in a function in a file to trace it
> >
> > (de go ()
> > ((quote (X) (* X X)) 9)
> > )
> >
> > but it's not giving me the step by step explanation I was hoping for
> >
> > : (trace go)
> > !? (method "X" C)
> > (('((X) (* X X)) 9)) -- Symbol expected
> > ?
> >
> > Any help to understand what's happening at each stage would be very much
> > appreciated.
> >
> > Thank you in anticipation.
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>