how to compile pil20 on termux

2020-11-22 Thread Bruno Franco
since it does not come as a termux package anymore, can I compile it on my
phone?


Re: vip send select lines to command window

2020-08-31 Thread Bruno Franco
thanks alex! It works perfectly

On Mon, Aug 31, 2020, 01:12 Alexander Burger  wrote:

> Hi Bruno,
>
> > In vip, if I have a file like:
> > _
> > # file with a single line of code
> > (prin "print me on the command window")
> > ___
> >
> > is there a way to select the line with the code and send it to the
> command
> > window for execution, like slime for emacs?
>
> Yes. Lisp expressions can be evaluaded in the command window by starting
> the
> line with a colon followed by a space. Without a space they are taken as a
> normal editor commands like ":e" or ":w".
>
> In Vip, the command window is a normal editor window. You can resize it
> with "+"
> and "-", and change the focus to it with "qj".
>
> Thus, to do what you ask above, copy the line with "yy", go to the command
> window, and type ":I: " to insert ": ", and hit .
>
> You can edit all lines in the command window by going up with "k", and re-
> executing them by pressing .
>
> To go directly from a normal edit window to the command window, you can
> also use
> ":" (like in Vim) or . Both print a ccolon. "/" is like in Vim, and
> "&"
> is similar but searches for Lisp words instead of normal (sub)strings:
> ""
> is analog to Vim's "/\".
>
> >From a normal edit window, typing two spaces, an expression, and 
> will
> evaluate it and immediately change the focus back to the original window.
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


vip send select lines to command window

2020-08-30 Thread Bruno Franco
In vip, if I have a file like:
_
# file with a single line of code
(prin "print me on the command window")
___

is there a way to select the line with the code and send it to the command
window for execution, like slime for emacs?


Re: Fridays for Functions (Was: PilCon 2020)

2020-07-02 Thread Bruno Franco
Unfortunately, 8 UTC is too early for me XD, I'll have to wait for the 16
UTC meeting

On Thu, Jul 2, 2020 at 12:06 PM C K Kashyap  wrote:

> I can't wait :)
>
> On Thu, Jul 2, 2020 at 9:46 AM Alexander Burger 
> wrote:
>
>> On Thu, Jul 02, 2020 at 09:28:09AM -0700, C K Kashyap wrote:
>> > Just to confirm - is this at 8am UTC on 3rd July?
>>
>> Yes, that's right. About 15 hours and 20 minutes from now ;)
>>
>> ☺/ A!ex
>>
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>


Re: PilCon 2020

2020-04-23 Thread Bruno Franco
I am interested too in an online conference. Its the only way I could
attend anyways. And saving it up for playback on youtube interests me.

On Thu, Apr 23, 2020 at 1:58 AM O.Hamann  wrote:

> Timely, short, clear communication, thank you for that, Alex.
>
>
> I do not really have any real experience with video conferences,
>
> but last year I attended a few presentations of a software conference
> via web and it was quite fun and very inspiring.
>
> So thumbs up for your idea - but all I could offer to make that happen
> is a little donation for bandwidth or hardware rental or so.
>
>
> I would appreciate the opportunity to see some infos concerning pil21
>
> or possibly to watch what others are working on with picolisp.
>
>
> Perhaps such a video conference could be a better chance for those who
> don't live in Germany
>
> to show sth to the community, which would be otherwise 'not worth' to
> travel around for.
>
>
> Kind regards,
>
> Olaf
>
>
>
>
> On 22.04.20 07:00, Alexander Burger wrote:
> > Hi all,
> >
> > yesterday the Oktoberfest, the largest annual event in Bavaria, was
> canceled.
> >
> > I think we will also have to cancel the other large event, PilCon. It is
> not
> > sure whether such events will be allowed legally by end of July, and how
> the
> > international travel situation will be.
> >
> > I hope this is OK for everybody.
> >
> > Would it make sense to plan an online conference instead? We are playing
> around
> > with Jitsi Meet currently. Any thoughts?
> >
> > ☺/ A!ex
> >
>
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>
>


Re: Interning symbols in lib/simul.l

2020-04-12 Thread Bruno Franco
thank you!

On Sun, Apr 12, 2020 at 2:01 AM Mike  wrote:

> > I'm studying lib/sumul.l, specifically the 'grid function.
>
> In my repo you would find a lot of usage examples for grid:
> https://git.envs.net/mpech/tankf33der/
>
> (mike)
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Interning symbols in lib/simul.l

2020-04-11 Thread Bruno Franco
I'm studying lib/sumul.l, specifically the 'grid function. I understand how
it works now, but I have two doubts:

1) why are symbols in the grid interned?
2) what does the F in FX and FY stand for?

here's the code for reference:

(de grid (DX DY FX FY)
   (let Grid
  (make
 (for X DX
(link
   (make
  (for Y DY
 (set
(link
   (if (> DX 26)
  (box)
  (intern (pack (char (+ X 96)) Y)) ) )  # why
are symbols interned here?
(cons (cons) (cons)) ) ) ) ) ) )
  (let West (and FX (last Grid))
 (for (Lst Grid  Lst)
(let
   (Col (++ Lst)
  East (or (car Lst) (and FX (car Grid)))
  South (and FY (last Col)) )
   (for (L Col  L)
  (with (++ L)
 (set (: 0 1) (++ West))  # west
 (con (: 0 1) (++ East))  # east
 (set (: 0 -1) South) # south
 (con (: 0 -1)# north
(or (car L) (and FY (car Col))) )
 (setq South This) ) )
   (setq West Col) ) ) )
  Grid ) )


Re: why is there no setf in picolisp?

2019-07-04 Thread Bruno Franco
all right, thanks!

On Thu, Jun 27, 2019 at 12:27 PM  wrote:

> So, reading Alex’s comments and also the definition of the “joke” `setf`
> here:
>
> On Thu, 27 Jun 2019 10:29 -04:00, Mike wrote:
>
> https://github.com/picolisp/picolisp/blob/dev/misc/setf.l
>
>
> informs me that the answer to Bruno’s question is: yes, the concept in
> fact *does* exist in picolisp (by the use of its `set` primitive),
> rendering such as a `setf` entirely unnecessary (and un-idiomatic as well).
>


why is there no setf in picolisp?

2019-06-26 Thread Bruno Franco
Soo, yeah. I'm studying common lisp, and coming from picolisp setf confused
me at first. The concept does not seem to appear on picolisp, and I
wondered why its not there.

The only reference I could find was this:
https://www.mail-archive.com/picolisp@software-lab.de/msg03604.html
it mentions that it "violates the spirit of how lisp functions evaluate
their arguments", but no more comment is made.

I hope I'm forgiven if a flame war starts, but I'm trying to understand
what makes a good lisp.

So, why is there no setf in picolisp?


What are the runtime tools?

2019-03-22 Thread Bruno Franco
What are they?


What parts of picolisp did you have the most trouble understanding?

2018-07-30 Thread Bruno Franco
three questions:
1) what parts of picolisp have you had trouble understanding? Which clashed
with your previous experience as a programmer?

2) What features of picolisp are you using right now? Did you learn
something interesting while using them that you would like others to know?

3) is there a part that you don't understand yet, but would like to master?

I wanna use the answers to these questions to make tutorials for the wiki.
To make the learning curve a little easier ;)


Re: A few questions from a confused lisper

2018-07-12 Thread Bruno Franco
actually, you could just put the function (mumble-mumble X) in the place
of Y:
(for X (1 2 3 4 5)
(NIL (mumble-mumble X)
(println "this does not work")) )


On Thu, Jul 12, 2018 at 9:27 PM Bruno Franco 
wrote:

> Well, for the conditional exit in the iterators (for, do, and loop),
> I would do something like this:
> (use Y
> (for X (1 2 3 4 5)
> (setq Y (mumble-mumble X))
> (NIL Y (println "this does not work")) ) )
>
> Though I'm not sure that is the most elegant way to go XD.
>
> As for the local exits, maybe an example of when you wanted to do one
> in picolisp would be useful to point you in the right direction.
>
> And the macros, here's a page that can help you find your way
> around not having them:
> https://picolisp.com/wiki/?macros
>
> also see the functions 'fill and 'macro.
> 'fill replaces each occurence of a pattern @Pat with its value in the
> list that you give it, and 'macro does the same, but evaluates the
> resulting list too.
>
> Hope this helps!
>
>
> On Thu, Jul 12, 2018 at 1:34 PM Johan Persson  wrote:
>
>> Hi, list!
>>
>> First I'd like to say that I'm having a blast playing around with
>> PicoLisp lately. (It only took me about seven years to get around to
>> it!) The fact that it exists and work as well as it does is a fresh and
>> bold counterpoint to the conventional wisdom of the current programming
>> language design canon. I love it.
>>
>> Anyhow, there are a few things that the Common Lisper in me find a bit
>> puzzling:
>>
>> First off, I'm confused about what the correct way of doing local exits.
>> There's no "return" or "return-from" -- instead the closest thing I've
>> found is "quit", which is sort of akin to "error" in CL, but without the
>> jump into the condition-system. It feels wrong. Is it wrong?
>>
>> Then there's the conditional exits in "for", "do" and "loop" which
>> presents a real problem if you wish to terminate the loop from within a
>> sub-clause:
>>
>>  (for X (1 2 3 4 5)
>>(let Y (mumble-mumble X)
>>   (NIL Y (println "this doesn't work"
>>
>> What's the correct way of doing this? Throw the value and catch it right
>> outside of the for-loop?
>>
>> I'm also a pathological meta-programmer, and the lack of macros doesn't
>> bother me as much as I thought it would. However, one thing I miss from
>> other lisps is a way of expanding macros. How would I go on about doing
>> that in PicoLisp?
>>
>> / Johan
>>
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>


Re: A few questions from a confused lisper

2018-07-12 Thread Bruno Franco
Well, for the conditional exit in the iterators (for, do, and loop),
I would do something like this:
(use Y
(for X (1 2 3 4 5)
(setq Y (mumble-mumble X))
(NIL Y (println "this does not work")) ) )

Though I'm not sure that is the most elegant way to go XD.

As for the local exits, maybe an example of when you wanted to do one
in picolisp would be useful to point you in the right direction.

And the macros, here's a page that can help you find your way
around not having them:
https://picolisp.com/wiki/?macros

also see the functions 'fill and 'macro.
'fill replaces each occurence of a pattern @Pat with its value in the
list that you give it, and 'macro does the same, but evaluates the
resulting list too.

Hope this helps!


On Thu, Jul 12, 2018 at 1:34 PM Johan Persson  wrote:

> Hi, list!
>
> First I'd like to say that I'm having a blast playing around with
> PicoLisp lately. (It only took me about seven years to get around to
> it!) The fact that it exists and work as well as it does is a fresh and
> bold counterpoint to the conventional wisdom of the current programming
> language design canon. I love it.
>
> Anyhow, there are a few things that the Common Lisper in me find a bit
> puzzling:
>
> First off, I'm confused about what the correct way of doing local exits.
> There's no "return" or "return-from" -- instead the closest thing I've
> found is "quit", which is sort of akin to "error" in CL, but without the
> jump into the condition-system. It feels wrong. Is it wrong?
>
> Then there's the conditional exits in "for", "do" and "loop" which
> presents a real problem if you wish to terminate the loop from within a
> sub-clause:
>
>  (for X (1 2 3 4 5)
>(let Y (mumble-mumble X)
>   (NIL Y (println "this doesn't work"
>
> What's the correct way of doing this? Throw the value and catch it right
> outside of the for-loop?
>
> I'm also a pathological meta-programmer, and the lack of macros doesn't
> bother me as much as I thought it would. However, one thing I miss from
> other lisps is a way of expanding macros. How would I go on about doing
> that in PicoLisp?
>
> / Johan
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: p :- p. in pilog

2018-07-10 Thread Bruno Franco
Thanks Alex, it worked exactly

On Tue, Jul 10, 2018, 00:46 Alexander Burger  wrote:

> Hi Bruno,
>
> > there is this rule in prolog:
> > p :- p.
> > That is infinitely recursive. If you query the database for
> > ...
> > How can you write p :- p. in pilog, so that it does the infinite loop
> that
>
>: (be p () (p))
>: (? (p))
>
> —Alex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


p :- p. in pilog

2018-07-09 Thread Bruno Franco
there is this rule in prolog:
p :- p.
That is infinitely recursive. If you query the database for
?- p.
It gets thrown into an infinite loop.

I've tried to recreate that in pilog, with no success.
: (be p (() p))

How can you write p :- p. in pilog, so that it does the infinite loop that
I expect?


Re: Pilog unification of a nested predicate

2018-07-03 Thread Bruno Franco
Oh, I see! Thanks!

On Tue, Jul 3, 2018 at 1:45 PM Alexander Burger  wrote:

> Hi Bruno,
>
> > (be vertical (line (point @X @Y) (point @X @Z)))
> > (be horizontal (line (point @X @Y) (point @Z @Y)))
> >
> > and the query:
> > (? (vertical line (point 1 2) (point 1 3)))
>
> Yes, OK, but then I would rather go with:
>
>(be vertical ((line (point @X @Y1) (point @X @Y2
>(be horizontal ((line (point @X1 @Y) (point @X2 @Y
>
> i.e. the matching single parameter is a (single) list of the form
>
>(line (point ..) (point ..))
>
>
> Then you get:
>
>: (? (vertical (line (point 1 2) (point 1 3
>-> T
>
>: (? (vertical (line (point 1 2) (point 3 4
>-> NIL
>
>: (? (vertical (line (point 1 2) (point @X 3
> @X=1
>-> NIL
>
> —Alex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Pilog unification of a nested predicate

2018-07-03 Thread Bruno Franco
oh yeah, the pilog definitions! sorry, here they are:

(be vertical (line (point @X @Y) (point @X @Z)))
(be horizontal (line (point @X @Y) (point @Z @Y)))

and the query:
(? (vertical line (point 1 2) (point 1 3)))

On Tue, Jul 3, 2018, 01:20 Alexander Burger  wrote:

> On Tue, Jul 03, 2018 at 12:21:13AM -0500, Bruno Franco wrote:
> > I had too many parentheses in the query.
> >
> > The correct form is:
> > (? (vertical line (point 1 2) (point 1 3)))
>
> No, this does not look right. We can't tell much unless we know all your
> definitions.
>
> —Alex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Pilog unification of a nested predicate

2018-07-02 Thread Bruno Franco
In this case, that is All the code.
These are some toy exercises in the book "Learn Prolog Now!",
and the complete code for that exercise is:

vertical(line(point(X,Y),point(X,Z))).
horizontal(line(point(X,Y),point(Z,Y))).


vertical(line(point(1,1),point(1,3))).

vertical(line(point(1,1),point(3,2))).

horizontal(line(point(1,1),point(2,Y))).

horizontal(line(point(2,3),P)).

The url is:
http://lpn.swi-prolog.org/lpnpage.php?pagetype=html=lpn-htmlse5

So yeah, I'm a noob on both Prolog And Pilog XD

On Tue, Jul 3, 2018 at 12:36 AM Johann-Tobias Schäg 
wrote:

> It would be interesting to see the complete code. with All definitions.
>
> *Von:* brunofrancosala...@gmail.com
> *Gesendet:* 3. Juli 2018 7:28 vorm.
> *An:* picolisp@software-lab.de
> *Antworten:* picolisp@software-lab.de
> *Betreff:* Re: Pilog unification of a nested predicate
>
> OK, I just got it XD
>
> I had too many parentheses in the query.
>
> The correct form is:
> (? (vertical line (point 1 2) (point 1 3)))
>
> But that leaves me with the question,
> Why is the syntax "(vertical line (..." instead of "(vertical (line ..." ?
>
> My best guess is that, internally, the symbol 'vertical gets consed into
> the rest of the predicate,
> as defined in its property list.
>
> that is, when you run:
> : (show 'vertical)
> vertical NIL
>T (((line (point @X @Y) (point @X @Z
> -> vertical
>
> the name of the sym (vertical) gets consed into the (line (point @X @Y)
> (point @X @Z)) part,
> and since that's what is used to unify the query,
> the query must have that same "(vertical line ..." structure.
>
> But that's just a guess. If there is some deeper meaning I would be happy
> to know :D
>
> On Mon, Jul 2, 2018 at 11:23 PM Bruno Franco 
> wrote:
>
>> The prolog saga continues!
>> This time, I'm having trouble with unification.
>>
>> I have this predicate:
>> vertical(line(point(X, Y), point(X, Z))).
>>
>> That gets unified with this query:
>> vertical(line(point(1, 2), point(1, 3))).
>>
>> In prolog, this returns true.
>>
>> But when I run what I (think) is the equivalent pilog code:
>>
>> (be vertical (line (point @X @Y) (point @X @Z)))
>> (? (vertical (line (point 1 2) (point 1 3
>>
>> The query returns NIL
>>
>> Is my syntax wrong? Or should I have specified some other intermediate
>> predicate?
>>
>> Thank you
>>
>


Re: Pilog unification of a nested predicate

2018-07-02 Thread Bruno Franco
OK, I just got it XD

I had too many parentheses in the query.

The correct form is:
(? (vertical line (point 1 2) (point 1 3)))

But that leaves me with the question,
Why is the syntax "(vertical line (..." instead of "(vertical (line ..." ?

My best guess is that, internally, the symbol 'vertical gets consed into
the rest of the predicate,
as defined in its property list.

that is, when you run:
: (show 'vertical)
vertical NIL
   T (((line (point @X @Y) (point @X @Z
-> vertical

the name of the sym (vertical) gets consed into the (line (point @X @Y)
(point @X @Z)) part,
and since that's what is used to unify the query,
the query must have that same "(vertical line ..." structure.

But that's just a guess. If there is some deeper meaning I would be happy
to know :D

On Mon, Jul 2, 2018 at 11:23 PM Bruno Franco 
wrote:

> The prolog saga continues!
> This time, I'm having trouble with unification.
>
> I have this predicate:
> vertical(line(point(X, Y), point(X, Z))).
>
> That gets unified with this query:
> vertical(line(point(1, 2), point(1, 3))).
>
> In prolog, this returns true.
>
> But when I run what I (think) is the equivalent pilog code:
>
> (be vertical (line (point @X @Y) (point @X @Z)))
> (? (vertical (line (point 1 2) (point 1 3
>
> The query returns NIL
>
> Is my syntax wrong? Or should I have specified some other intermediate
> predicate?
>
> Thank you
>


Re: A query in Pilog

2018-07-02 Thread Bruno Franco
>If it does not work it is not because the >programming language or because
>some arbitrary, arcane rules you will >never understand. If PicoLisp does
not >do what you want it is because "You are >to dumb

Yeah, it can be very frustrating. But I like it in the long run. Since it
is so simple, it is easy to understand, and once you get it you rarely make
the same mistake again.

And that's something I like about this community. Even if I am too dumb to
get it, there is someone else smart enough to guide me the correct way : )

Thanks again!

On Mon, Jul 2, 2018, 00:14 Johann-Tobias Schäg  wrote:

>
> That is the horrible thing about PicoLisp. If it does not work it is not
> because the programming language or not because some arbitrary, arcane
> rules you will never understand. If PicoLisp does not do what you want it
> is because "You are to dumb to understand a simple system of simple rules"
> or something like that. This can be very insulting if you take it too
> personal.
>
> But on the other side of the coin, you wouldn't wanna miss such stark
> direct feedback as a NIL. Sometimes it is just what you deserve and need.
> *Von:* brunofrancosala...@gmail.com
> *Gesendet:* 2. Juli 2018 5:46 vorm.
> *An:* picolisp@software-lab.de
> *Antworten:* picolisp@software-lab.de
> *Betreff:* Re: A query in Pilog
>
> OH, I just realized how!
>
> (? (loves Mark @X) (woman @X))
>
> It seems obvious in hindsight XD
>
> On Sun, Jul 1, 2018 at 10:37 PM Bruno Franco 
> wrote:
>
>> Yeah! that is exactly right!
>>
>> All this time I had tried to use the "?" function like this:
>> (? ((loves Mark @X) (woman @X)))
>> But it returned NIL.
>>
>> So, when you search for a variable that can satisfy more than one
>> predicate,
>> you make a list of predicates (call it PList) and pass it as argument to
>> (prove (goal PList)).
>>
>> Is there a way to do that using only the "?" function, or must it always
>> be wrapped by the (prove (goal )) combo?
>>
>>
>> On Sun, Jul 1, 2018 at 6:05 PM Johann-Tobias Schäg 
>> wrote:
>>
>>> I've got it working the following way. It is very inelegant but it shows
>>> the idea.
>>>
>>>  (be woman (Ann))
>>> #-> woman
>>> (prove (goal (woman @X))) # wrong
>>> #!? (woman @X)
>>> #woman -- Undefined
>>> (prove (goal '((woman @X #quoted list can contain multiple statements
>>> #-> ((@X . Ann))
>>> (be loves (Mark Ann))
>>> #-> loves
>>> (be loves (Mark Max))
>>> #-> loves
>>> (prove (goal '((loves Mark @X) (woman @X #as is seen here
>>> #-> ((@X . Ann))
>>>
>>> does that help?
>>>
>>> *Von:* brunofrancosalamin@gmailcom 
>>> *Gesendet:* 1. Juli 2018 11:49 nachm.
>>> *An:* picolisp@software-lab.de
>>> *Antworten:* picolisp@software-lab.de
>>> *Betreff:* A query in Pilog
>>>
>>> I'm going through the "Learn Prolog Now!" ebook and I ran into this
>>> query:
>>>
>>> ?- loves(marsellus,X), woman(X).
>>>
>>> And I can't figure out how to do it in pilog.
>>> Is there a function that can test multiple queries at once, like or/2
>>> does?
>>>
>>> thanks
>>>
>>


Re: Reminder on Wiki survey

2018-07-01 Thread Bruno Franco
done, voted

On Sat, Jun 30, 2018 at 9:44 AM Joe Golden  wrote:

> Hey!  Vote!  It's simple and painless ;-)
>
> On Sat, Jun 30, 2018 at 04:01:50PM +0200, Manuel Cano wrote:
> >Hi,
> >
> >Hey! Vote! I've did it some days ago.
> >
> >
> >Kind regards,
> >Manu
> >
> >2018-06-30 14:10 GMT+02:00 Arie van Wingerden :
> >
> >> Thanks!
> >>
> >> Op za 30 jun. 2018 om 13:59 schreef Timur Ismagilov :
> >>
> >>> I voted. Just letting you know.
> >>>
> >>> — bouncepaw
> >>>
> >>>
> >>>  Исходное сообщение 
> >>> От: Arie van Wingerden 
> >>> Дата: 30.06.2018 16:20 (GMT+05:00)
> >>> Кому: picolisp@software-lab.de
> >>> Тема: Reminder on Wiki survey
> >>>
> >>> Hi,
> >>>
> >>> we got 9 responses so far, but we guess there are a lot more
> participants
> >>> / lurkers in this mailing list.
> >>>
> >>> Please fill out the survey here if you haven't done that yet:
> >>> https://esurv.org/?s=MOIEMH_753ad7ff
> >>>
> >>> Thanks to those who already did participate :)
> >>>
> >>> Best,
> >>>Arie
> >>>
> >>
>
> --
> Joe Golden
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: A query in Pilog

2018-07-01 Thread Bruno Franco
OH, I just realized how!

(? (loves Mark @X) (woman @X))

It seems obvious in hindsight XD

On Sun, Jul 1, 2018 at 10:37 PM Bruno Franco 
wrote:

> Yeah! that is exactly right!
>
> All this time I had tried to use the "?" function like this:
> (? ((loves Mark @X) (woman @X)))
> But it returned NIL.
>
> So, when you search for a variable that can satisfy more than one
> predicate,
> you make a list of predicates (call it PList) and pass it as argument to
> (prove (goal PList)).
>
> Is there a way to do that using only the "?" function, or must it always
> be wrapped by the (prove (goal )) combo?
>
>
> On Sun, Jul 1, 2018 at 6:05 PM Johann-Tobias Schäg 
> wrote:
>
>> I've got it working the following way. It is very inelegant but it shows
>> the idea.
>>
>>  (be woman (Ann))
>> #-> woman
>> (prove (goal (woman @X))) # wrong
>> #!? (woman @X)
>> #woman -- Undefined
>> (prove (goal '((woman @X #quoted list can contain multiple statements
>> #-> ((@X . Ann))
>> (be loves (Mark Ann))
>> #-> loves
>> (be loves (Mark Max))
>> #-> loves
>> (prove (goal '((loves Mark @X) (woman @X #as is seen here
>> #-> ((@X . Ann))
>>
>> does that help?
>>
>> *Von:* brunofrancosala...@gmail.com
>> *Gesendet:* 1. Juli 2018 11:49 nachm.
>> *An:* picolisp@software-lab.de
>> *Antworten:* picolisp@software-lab.de
>> *Betreff:* A query in Pilog
>>
>> I'm going through the "Learn Prolog Now!" ebook and I ran into this query:
>>
>> ?- loves(marsellus,X), woman(X).
>>
>> And I can't figure out how to do it in pilog.
>> Is there a function that can test multiple queries at once, like or/2
>> does?
>>
>> thanks
>>
>


Re: A query in Pilog

2018-07-01 Thread Bruno Franco
Yeah! that is exactly right!

All this time I had tried to use the "?" function like this:
(? ((loves Mark @X) (woman @X)))
But it returned NIL.

So, when you search for a variable that can satisfy more than one predicate,
you make a list of predicates (call it PList) and pass it as argument to
(prove (goal PList)).

Is there a way to do that using only the "?" function, or must it always be
wrapped by the (prove (goal )) combo?


On Sun, Jul 1, 2018 at 6:05 PM Johann-Tobias Schäg 
wrote:

> I've got it working the following way. It is very inelegant but it shows
> the idea.
>
>  (be woman (Ann))
> #-> woman
> (prove (goal (woman @X))) # wrong
> #!? (woman @X)
> #woman -- Undefined
> (prove (goal '((woman @X #quoted list can contain multiple statements
> #-> ((@X . Ann))
> (be loves (Mark Ann))
> #-> loves
> (be loves (Mark Max))
> #-> loves
> (prove (goal '((loves Mark @X) (woman @X #as is seen here
> #-> ((@X . Ann))
>
> does that help?
>
> *Von:* brunofrancosala...@gmail.com
> *Gesendet:* 1. Juli 2018 11:49 nachm.
> *An:* picolisp@software-lab.de
> *Antworten:* picolisp@software-lab.de
> *Betreff:* A query in Pilog
>
> I'm going through the "Learn Prolog Now!" ebook and I ran into this query:
>
> ?- loves(marsellus,X), woman(X).
>
> And I can't figure out how to do it in pilog.
> Is there a function that can test multiple queries at once, like or/2 does?
>
> thanks
>


A query in Pilog

2018-07-01 Thread Bruno Franco
I'm going through the "Learn Prolog Now!" ebook and I ran into this query:

?- loves(marsellus,X), woman(X).

And I can't figure out how to do it in pilog.
Is there a function that can test multiple queries at once, like or/2 does?

thanks


Re: your mail

2017-08-26 Thread Bruno Franco
That is just what I needed! thanks alex

On Sat, Aug 26, 2017 at 12:32 AM, Alexander Burger 
wrote:

> Hi Bruno,
>
> > I'm writing a script that shows a person a math expression (like "2 + 3")
> > waits for an answer, then returns if its right or wrong.
> > What I want though, is for it to wait something like 3 seconds and, if
> > there is no input, assume the user doesn't know and return "WRONG".
>
> The easiest is if you just wait for the next key stroke:
>
>(key 3000)
>
> this returns the key if one was pressed, otherwise NIL.
>
>
> To wait for a full line of input, you could use 'abort':
>
>(abort 3 (line T))
>
> This also returns the line, or NIL if timed out.
>
> ♪♫ Alex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


[no subject]

2017-08-25 Thread Bruno Franco
Hi list,

I'm writing a script that shows a person a math expression (like "2 + 3")
waits for an answer, then returns if its right or wrong.
What I want though, is for it to wait something like 3 seconds and, if
there is no input, assume the user doesn't know and return "WRONG".

I thought of using 'later, in something like:

(setq A '(NIL))
(later A (timeout 3000) (in NIL (line T)))
(wait 3000)
(if (car A)
   "RIGHT"
   "WRONG" )

That is, make a child process in parallel, have It die after 3 seconds of
waiting for input, wait for three seconds, and do something depending on
whether the child returned a value (if it didn't, it timed out before the
user answered).
but I don't know how to connect the new input channel to the current
terminal.

So the questions are:
1) how to get the child to take over the input channel of the parent,
2) Is this the best way to do it? is there a better way?

Thanks


Re: single letters

2017-06-23 Thread Bruno Franco
Hi Alex, Geo.

Ok, so the lower-case upper-case testing and mapping is actually encoded
into these lists, and the function charType takes the character number in
unicode, modifies it, and uses that as an index in the lists to get that
information. No lookup in a special file. Thanks for correcting my mistake.

On Mon, Jun 19, 2017 at 10:19 PM, George Orais  wrote:

> Hi Bruno,
>
> No problem! Glad to hear I was able to help :)
>
> I'm still working on the FPGA version of PicoLisp VM so most of the time I
> also do these comparison to have a better understanding how the VM is
> implemented.
>
>
> BR,
> geo
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: single letters

2017-06-18 Thread Bruno Franco
Hi Geo! Thanks a lot for the info!
I did a google search and it turns out Unicode does come with several text
files that create mappings between letters of different cases. The most
important one is UnicodeData.txt. It has the one to one mappings between
lower and upper case.
Though my quick google search didn't turn up results for how kaffe deals
with case mappings, I guess the likely thing is that picolisp uses a text
file just like that for its case management.
Thanks for the pointers to the source, too. When I first looked at the
64-bits source I didn't understand it, but with the comparison with the
32-bit source I get a better idea of what it does. I'll use the contrast
between the two from now on to study it better.

On Sun, Jun 18, 2017 at 11:04 PM, Tamas Herman 
wrote:

> I'm a bit surprised about these questions.
> Can't you just peek into the source of low? and upp? even from the REPL?
>
> I'm not using picolisp lately but I remember vaguely it had the same
> feature as Clojure:
>
> => (source clojure.string/upper-case)
>
> (defn ^String upper-case
>   "Converts string to all upper-case."
>   {:added "1.2"}
>   [^CharSequence s]
>   (.. s toString toUpperCase))
>
> --
>   tom
>


Re: single letters

2017-06-18 Thread Bruno Franco
On the subject of low? and upp?, how does picolisp know if a character is
upper or lower case?
Is there a list of all upper and lower case characters built in to the
interpreter, and the character is checked against that list?
Or is casing information is built into unicode?

On Sat, Jun 17, 2017 at 6:19 AM, Alexander Burger 
wrote:

> Hi Geo,
>
> On Sat, Jun 17, 2017 at 06:07:16AM +, George Orais wrote:
> > (de singleLetter? (item)   (and (=1 (length item)) (or (low? item) (upp?
> item
>
> Yes, 'low?' and "upp?" are a good idea. They do however return true also
> for
> letters like "ä" / "Ä", so it depends on what the exact task is

Re: Penti keyboard doesn't seem to recognize more than two inputs

2017-05-31 Thread Bruno Franco
Hi Alex.

> does "multitouch" just mean more than one finger?

Apparently yes. I just downloaded an app to test the maximum multitouch
input and it is, indeed, two. I'll go to my vendor and see if I can get my
phone exchanged for one that can at least get up to 5.

Thanks for the quick response!


Penti keyboard doesn't seem to recognize more than two inputs

2017-05-30 Thread Bruno Franco
Alex's explanation of his workflow got me exited, so I've downloaded the
Penti keyboard. I installed it and set it up as the default keyboard, and
it runs! Penti is written in big letters on the screen, but when I tap my 5
fingers to start it the shadows only appear under two of the fingers, and
the input circles never appear.

I've downloaded Penti a couple of times and reinstalled it, as well as
restarting the phone, but the problem is still there.

Has this happened to anyone before? Is there some advice you could give me?
Some dependency I'm missing?

If you have any questions, I'll do my best to answer them. Thank you for
your time.

I'm using a samsung galaxy J2 Prime, with android version 6.0.1


Re: Error running vip

2017-05-18 Thread Bruno Franco
Yes! Its working. Thanks Alex. I hadn't realized my version was so old
because the version listed in the download page is 16.12.8. I'll check the
current verison list from now on.

On Thu, May 18, 2017 at 3:32 AM, Alexander Burger 
wrote:

> Hi Bruno,
>
> > Looking at the source, this is the line that is referenced by the error:
> >
> > (local) [*CmdWin *Flat *Chr *Complete *Repeat *Change *Count *Cnt *Search
> > *Clip]
> >
> > My guess is that it is interpreting *CmdWin as a function, since it is
> the
> > first element of a list.
>
> This is because you have a too-old version of PicoLisp. The mechanics of
> 'symbols' and 'local' were changed on 06mar17.
>
> ♪♫ Alex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Error running vip

2017-05-18 Thread Bruno Franco
Hi list,
I just downloaded the latest version of vip (06may17), but when I try to
run it, it returns an error and enters the picolisp cli:
 ~> vip
[/home/bruno/bin/vip:5] !? (*CmdWin *Flat *Chr *Complete *Repeat *Change
*Count *Cnt *Search *Clip)
*CmdWin -- Undefined
? ⏎

Looking at the source, this is the line that is referenced by the error:

(local) [*CmdWin *Flat *Chr *Complete *Repeat *Change *Count *Cnt *Search
*Clip]

My guess is that it is interpreting *CmdWin as a function, since it is the
first element of a list.

I would appreciate any guidance to getting vip to run.


Re: Is there documentation for the libraries in @lib/ ?

2017-04-08 Thread Bruno Franco
Thanks Henrik, I didn't know about the select documentation. And I'll make
sure to check the pl-web library

On Sat, Apr 8, 2017 at 6:09 PM, Henrik Sarvell <hsarv...@gmail.com> wrote:

> http.l
> Is the base logic for the out of the box app functionality, a lot of it
> has to do with parsing and building http requests. With this file you can
> launch your own http server. It's the basis (as in copy paste with some
> modifications) for my own "web stack" as well: https://bitbucket.org/
> hsarvell/pl-web
>
> pilog.l
> I don't know about direct documentation as in an explanation of every code
> block in that file but this is probably helpful:
> https://software-lab.de/doc/select.html
>
>
>
> On Sun, Apr 2, 2017 at 7:16 AM, Joh-Tob Schäg <johtob...@gmail.com> wrote:
>
>> Yes you can not find any documentation.
>>
>> 2017-04-02 3:36 GMT+02:00 Bruno Franco <brunofrancosala...@gmail.com>:
>>
>>> I can find the documentation for the default functions, and for the form
>>> functions, but how about libraries like pilog.l or http.l?
>>>
>>
>>
>


Re: Evaluation misstep in tag function

2017-04-05 Thread Bruno Franco
Ah, I see! So, its for convenience that the atoms are printed. And the
reason `(+ 1 1) was printed was that it was first evaluated to 2, *then*
passed to , who only ever saw the atom 2.
Thanks Alex.

On Wed, Apr 5, 2017 at 1:36 AM, Alexander Burger 
wrote:

> Hi Bruno,
>
> > I'm going through the picolisp application development tutorial (
> > http://software-lab.de/doc/app.html#tags) and I'm trying this piece of
> code
> > at the tags section:
> >
> > : ( 'main
> >( NIL "Head")
> >( NIL
> >   ( "Line 1")
> >   "Line"
> >   ()
> >   (+ 1 1) ) )
> > Head
> > Line 1
> > Line
> > 
> >
> > That is, the (+ 1 1) part is not evaluated.
>
> In fact it *is* evaluated, but it does not print anything.
>
> All those HTML functions are *print* front-ends, which send text to the
> current
> output channel.
>
>: ( NIL "Head")
>Head
>
> is nothing more than
>
>: (prinl "Head")
>Head
>
> just in a more convenient form.
>
> The nice thing is that these functions may be nested, as can be seen in
> your
> example ( 'main ( NIL "Head") ..). Still they must print
> somewhere at
> the bottom.
>
> So the answer to your question is to write
>
>(ht:Prin (+ 1 1))
>
> or just
>
>(prin (+ 1 1))
>
> ('ht:Prin' is recommended for textual data which may contain HTML meta
> characters
> to properly escape them)
>
>
> Note that - for convenience - *atomic* expressions (like "Head" or "Line"
> in
> your example) are printed directly, so that it is not necessary to write
>
>( NIL (prin "Head"))  # Not needed
>
> This is also mentioned in doc/app.html as
>
>• If an argument is an atom (a number or a symbol (string)), its value
> is
>  printed immediately.
>
>• Otherwise (a list), it is evaluated as a Lisp function (typically
> some form
>  of print statement).
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Evaluation misstep in tag function

2017-04-04 Thread Bruno Franco
Hi list,

I'm going through the picolisp application development tutorial (
http://software-lab.de/doc/app.html#tags) and I'm trying this piece of code
at the tags section:

: ( 'main
   ( NIL "Head")
   ( NIL
  ( "Line 1")
  "Line"
  ()
  (+ 1 1) ) )
Head
Line 1
Line 2


the problem is that, when I run it, I get this:

: ( 'main
   ( NIL "Head")
   ( NIL
  ( "Line 1")
  "Line"
  ()
  (+ 1 1) ) )
Head
Line 1
Line


That is, the (+ 1 1) part is not evaluated.

I run it both as a file loaded from the terminal by pil in a session started as:
pil @lib/http.l @lib/xhtml.l @lib/form.l --server 8080 project.l

And in a modified version of psh, but still the (+ 1 1) is not evaluated.

The evaluation only happens if I add an accent to the (+ 1 1)
( 'main
  ( NIL "Head")
  ( NIL
 ( "Line 1")
 "Line"
 ()
 `(+ 1 1) ) )
Head
Line 1
Line2


It also works if I just put the number, and if I nest it in a print
statement, like
(prin (+ 1 1)).

Can someone help me figure why this happens?


Is there documentation for the libraries in @lib/ ?

2017-04-01 Thread Bruno Franco
I can find the documentation for the default functions, and for the form
functions, but how about libraries like pilog.l or http.l?


Re: How to pass arguments to a script from the terminal?

2017-03-21 Thread Bruno Franco
Got it. Thanks!

On Tue, Mar 21, 2017 at 1:56 PM, Alexander Burger 
wrote:

> On Tue, Mar 21, 2017 at 10:35:34AM -0700, Lindsay John Lawrence wrote:
> > http://software-lab.de/doc/refA.html#argv
>
> Or use 'opt'
>
> (while (opt)
>(println @) )
> (bye)
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


How to pass arguments to a script from the terminal?

2017-03-21 Thread Bruno Franco
I want to write a simple script that would accept names from the command
line and print then, like this:

$ ./script alice bob
Hello alice and bob

I know that once picolisp has the names I would just use 'print', but how
do I pass the names?


Re: Role of 'wait' in a parallel program

2017-03-15 Thread Bruno Franco
I see, 'later' itself sets up *Run.
Thanks Alex

On Wed, Mar 15, 2017 at 1:21 AM, Alexander Burger 
wrote:

> Hi Bruno,
>
> > Joh-Tob's question got me curious about parallel code in picolisp. I've
> > studied the example of 'later' in the documentation and I have an idea of
> > how it works, but I don't understand how 'wait' works inside of it.
> > I understand *what* it does, it makes sure that the child processes
> finish
> > before returning the value for the whole expression.
>
> Right.
>
> > But I don't understand
> > *how* it works because, in the form of 'wait' that is used, *Run should
> be
> > executed each time the prg returns false. Yet *Run is not set to any
> value
> > in the code.
>
> In fact, *Run' is set, because 'later' installs a 'task' listening at the
> pipe
> to the child process:
>
>   ...
>   (task (pipe (pr (prog . "@Prg")))
>  ...
>
>
> > Here's the code for reference:
> > : (prog1
> > (mapcan '((N) (later (cons) (* N N))) (1 2 3 4))
> > (wait NIL (full @)) )
> > -> (1 4 9 16)
> >
> > I would also appreciate if someone could check if my idea of what is
> going
> > on in the code is correct:
> >
> > First, mapcan is executed. For each element in (1 2 3 4) a child process
> is
> > started, and the result of each operation is stored in a cons pair:
> '(NIL).
> > Every cons pair is concatenated into a list, which looks like '(NIL NIL
> NIL
> > NIL) in this case. Note that the list is built *before* any of the child
> > processes is completed, and since concatenation is destructive the result
> > will be stored in the appropriate position in this list whenever the
> child
> > process is finished. (wait NIL (full @)) checks that all these processes
> > are done before ending the prog1.
>
> Yes, this is absolutely correct.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Unclear licensing

2017-03-13 Thread Bruno Franco
I think that what Christopher means is that adding a licence makes the
developer's wishes clear. When you put a permissible licence its obvious
you don't care what people do with the code, but if there's no licence at
all it *could* mean you don't care, or it *could* mean you do care but just
forgot to say it. In the case with no licence, there will be people who
would like to use the code however they want, but stop because they're not
sure the developer would accept it. This is not a problem with anyone in
this community, who knows the code is free to use for anyone. It is more
for people who find the code without knowing anything about the developer.

On Mon, Mar 13, 2017 at 3:38 AM, Joh-Tob Schäg  wrote:

> Hi Christopher,
>
> You can interpret the:
>
>> Thanks for your concerns! But I still do not see where the problem is. I
>> don't
>> care what others do with the code. It is free!
>
> As make a ~fork~ of it which adds license headers you seem to desperately
> want.
>
> 2017-03-13 7:57 GMT+01:00 Alexander Burger :
>
>> Hi Christopher,
>>
>> > Nevertheless, I would strongly recommend *at least* putting licensing
>> > information on the JavaScript files, even if only using the one-liner
>> > approach. Since the JavaScript will usually be served through a Web
>> > server, it will be impossible for Web users to tell that it is freely
>> > licensed code. Code with unclear licensing is no better than proprietary
>> > code for practical purposes.
>>
>> Thanks for your concerns! But I still do not see where the problem is. I
>> don't
>> care what others do with the code. It is free!
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: Future of PicoLisp?

2017-02-03 Thread Bruno Franco
As for ubuntu, maybe you could make a Personal Package Archive (PPA). Its
lets you make your own packages that can be downloaded by users using
apt-get. Its as easy as downloading the normal packages, but the user must
manually add the repository.

Here's a useful link:
http://askubuntu.com/questions/71510/how-do-i-create-a-ppa

It would be more work than having the ubuntu team providing the package in
the official repositories, and I think you would have to make a new package
for every version of ubuntu you want to support. But its also the only way
to make sure that users get the most recent version of the software. As
Edgaras said, ubuntu is bad at keeping up with the newest releases.

I'm personally ok with compiling picolisp myself. But I know I wouldn't
have tried it if it had not been available as a package from ubuntu.

As Dean said, if there's anything we can do, let us know.

On Fri, Feb 3, 2017 at 10:31 AM, Alexander Burger 
wrote:

> Hi Dean,
>
> > Assuming that Wine packages are more numerous than Picolisps...you could
> do
> > a native Windows version in Powerbasic for Wine. Not only would this up
>
> Well, but then we can go as well with ErsatzLisp, the Java version of
> PicoLisp.
>
> A full PicoLisp doesn't yet run on Windows, as PicoLisp needs a POSIX
> runtime
> environment. Might be possible in the future with Joe's midipix port.
>
>
> > I smiled when I saw your reasons for moving from C to asm because
> > Powerbasic does ALIGN etc in it's stride without needing to drop down to
> > it's industrial strength built in assembler.
>
> Aligning is not so much a problem. But can you control the stack layout,
> condition codes (carry flag etc.) and multiple function entry points in
> Powerbasic? Or do natice calls to external C functions in a completely
> dynamic
> way. All this is not even possible in C.
>
>
> > I'd prefer to work in 64 bit asm but would be very happy to assist you in
> > any way I can to see Picolisp do well as I'm sure others would be.
> Whatever
> > you decide just let us know how we can help. I'm very new to Picolisp but
> > can already see that it's much too good not to do well.
>
> Thanks for the feedback! Let's see what happens. For Ubuntu 17.04 it is
> probably
> too late by now.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: matching a simple string variable

2017-01-02 Thread Bruno Franco
I think you're right on what's the problem. Chopping the varstring creates
a list of characters,
("C" "I" "T" "Y"), and the final list would look like '(@A ("C" "I" "T"
"Y") @B), which does
not match '(@A "C" "I" "T" "Y" @B) above.

If you want
(match '(@A (chop varstring) @B) description)
to match
(match '(@A "C" "I" "T" "Y" @B) description)
you'll have to add a tilde before chop, like this:
(match '(@A ~(chop varstring) @B) description)

The tilde is a read macro, and it will splice the result into the list. You
can read more about
read macros here: http://software-lab.de/doc/ref.html#macro-io

That said, do you think you could keep "CITY" intact inside the list,
without cutting it into
its letters? I mean, would
(match '(@A "CITY" @B) description)
work for what you want to do?

Because if it does, then you can write:
  (setq varstring "CITY")
  (match '(@A varstring @B) description)
which is much simpler than the first solution I gave.

On Mon, Jan 2, 2017 at 10:52 PM, Joe Golden  wrote:

> I'm trying to do some simple string matching and find match works nicely
> when the string is a literal list of chars like
>
>   (match '(@A "C" "I" "T" "Y" @B) description)
>
> but I need to match on a variable string stored in varstring which then
> needs to get chopped (I think).  I'm running into problems with
>
>   (setq varstring "CITY")
>   (match '(@A (chop varstring) @B) description)
>
> perhaps the function in the middle of the quote is the problem?  Or the
> extra list introduced by chop?
>
> Any guidance appreciated.
> --
> Joe Golden
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Vip Editor

2017-01-02 Thread Bruno Franco
Downloaded and Installed! Thanks Alex!

On Mon, Jan 2, 2017 at 2:29 AM, Alexander Burger 
wrote:

> Hi all,
>
> here is an article about Vip, the Vi-Style Editor in PicoLisp:
>
>http://picolisp.com/wiki/?vip
>
> It consists of only 990 lines of code.
>
> Not that the world needs yet another editor! But it may serve as a useful
> collection of PicoLisp coding examples :)
>
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: qurious quoting

2017-01-02 Thread Bruno Franco
ok, so " ' " is a read macro which expands to a list with the symbol quote
as car. I still don't understand how it gets translated into a different
printed result, but that is probably because, as you said, I just have not
drawn enough memory cell diagrams. I'll keep practising until I get it.
Thanks Joh.

Thank you too Danilo. I didn't know you could visualise the tree structure
using view. Than will be quite useful.

On Sun, Jan 1, 2017 at 6:09 PM, Joh-Tob Schäg  wrote:

> Are there any questions remaining?
> Am 01.01.2017 16:43 schrieb "Danilo Kordic" :
>
>> : (setq E
>> '(= (quote 'quote quote)
>> (quote (quote . quote) quote)
>> (quote . ((quote . quote) . (quote . NIL))) ) )
>> : (eval E)
>> -> T
>> : (view (cadr E))
>> +-- quote
>> |
>> +---+-- quote
>> |   |
>> |   quote
>> |
>> +-- quote
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>


Re: Advice on learning the picolisp asm?

2017-01-02 Thread Bruno Franco
Thanks for the advice guys. I hadn't even thought of checking the
documentation that actually *came* with the language. I've realised that
the assembly part of pico is still too big for me to chew on, but I'll keep
my eye on it. After all, part of the allure of the language is that I might
be able to understand the Entire Thing someday.

On Sat, Dec 31, 2016 at 8:56 AM, Alexander Burger <a...@software-lab.de>
wrote:

> On Sat, Dec 31, 2016 at 01:49:28PM +0100, Joh-Tob Schäg wrote:
> > I think if Regenaxer adds a new function the function pointer and thereby
> > the binary(assembly code) becomes invalid.
>
> You misunderstood the question.
>
> > > On Sat, Dec 31, 2016 at 12:28:06AM -0500, Bruno Franco wrote:
> > > > I don't really know any asm, but since the asm code for the picolisp
> > > > functions is just a (vi 'function) away, I feel tempted to try.
>
> (vi 'function) edits the (Assembly- or Lisp-) *source* of 'function'.
>
> This has nothing to do with the function pointer, i.e. the address the
> machine
> code gets loaded to by the system linker at runtime. And this address is
> not
> predictable at all, it may even change upon each invocation of the binary,
> depending on the linker and kernel's memory policy.
>
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: What is the difference between set and setq?

2016-12-30 Thread Bruno Franco
> This might be a nice thing to add to the documentation too,
> since the function definitions don't mention it.

Sorry, I was completely wrong. The definition of set and setq Do mention
whether the first argument is evaluated or not. I just didn't notice the
quote in the form of the general function.

On Wed, Dec 28, 2016 at 4:35 PM, Bruno Franco <brunofrancosala...@gmail.com>
wrote:

> >The same meaning of "eq" (or "quick") have functions like 'delete' /
> 'delq',
> >'assoc' / 'asoq', 'case' / 'casq' or 'push1' / 'push1q'.
>
> Thank you Alex, that was exactly my next question.
>
> On Tue, Dec 27, 2016 at 9:20 AM, Erik Gustafson <
> erik.d.gustaf...@gmail.com> wrote:
>
>> It is the *function* call overhead, which is relatively expensive. [..]
>>
>>
>> Thanks Alex, this is great. I'll add to the wiki article later today.
>>
>>
>


Re: Date query question

2016-12-29 Thread Bruno Franco
Hi Alex.
A picolisp clone of VI? That sounds awesome! Please do write the article
for the wiki.
Also, where do I find the source code?

On Thu, Dec 29, 2016 at 2:31 AM, Alexander Burger <a...@software-lab.de>
wrote:

> On Wed, Dec 28, 2016 at 07:47:13PM -0500, Bruno Franco wrote:
> > This is a tangent on your conversation, but...
> > Alex, that graph looks so cool. Did you do it by hand or did you use some
> > juicy picolisp program that I can get my hands on?
>
> No, just with VI.
>
> In fact you are right, because it was a version of VI written in PicoLisp
> (called 'vip'), which is my standard editor now, and thus also the editor
> used
> by my 'mutt' mail client.
>
> I plan to write a wiki article about 'vip' soon.
>
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Date query question

2016-12-28 Thread Bruno Franco
This is a tangent on your conversation, but...
Alex, that graph looks so cool. Did you do it by hand or did you use some
juicy picolisp program that I can get my hands on?

On Wed, Dec 28, 2016 at 5:45 AM, Alexander Burger 
wrote:

> On Wed, Dec 28, 2016 at 10:26:22AM +0100, Alexander Burger wrote:
> >(let Today (date)
> >   (collect 'sDate '+Proj (list Today Today) (list NIL T)) )
>
> The 'list' is of course not necessary:
>
>(collect 'sDate '+Proj (list Today Today) '(NIL T))
>
>
> But probably it is better anyway to scan both index parts in the same
> direction
> (upwards).
>
> Also, if I remember correctly, 'T' cannot be used for "infinite" here, the
> value
> for +UB trees must be a number or NIL (same as 0). So you can just use a
> number
> greater than any possible date, like (date 99) -> (2738 1 25)
>
>(collect 'sDate '+Proj (list NIL Today) (list Today 9))
>
> Sorry, nothing tested ;)
>
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Functional Arguments

2016-12-28 Thread Bruno Franco
Thanks Alex.
I didn't know about picolisp's tolerance for nested symbols. Is there a
reason you chose this?
Like, it lets you write some cool code, or it makes the language more
robust?

On Tue, Dec 27, 2016 at 10:15 AM, Alexander Burger 
wrote:

> Hi all,
>
> while talking about 'set' and 'setq', let me clarify another issue. Quite
> often
> I see here - or in IRC - expressions like
>
>(mapc 'set '(A B C) (1 2 3))
>
> or
>
>(mapcar 'inc (4 5 6))
>
> While this certainly works, it is actually wrong, or at least unnecessary.
>
>
> The mapping functions want a *functional* first argument. If you look up
> in the
> reference (under "Evaluation", doc/ref.html#ev), it says that a function is
> either a number (a function pointer) or a cell (with parameter(s) in the
> CAR and
> a 'prg' body in the CDR).
>
> However, the above expressions pass a *symbol* to the mapping functions.
> So just
>
>(mapc set '(A B C) (1 2 3))
> or
>(mapcar inc (4 5 6))
>
> would be fine, because the first arguments are evaluated, resulting in
> proper
> numbers.
>
>
> The quoted calls (resulting in symbols) happen to work just due to a lucky
> coincidence:
>
> When PicoLisp evaluates a function call, it tries to be tolerant. Instead
> of
> throwing an error when hitting a symbol, it *evaluates* that symbol (or any
> expressions in general which show up, until it gets to a proper function.
> For
> example
>
>(de square (N)
>   (* N N) )
>
>(setq
>   F 'square )
>   L '(line square circle) )
>
>: (F 7)
>-> 49
>
>: ((cadr L) 7)
>-> 49
>
>: ((val (cadr L)) 7)
>-> 49
>
>
> One more note: In case of *message* calls on objects you *must* pass a
> symbol.
> They need a symbol to locate the right method in the class hierarchy
>
>(mapc 'lose> (collect 'key '+Cls))
>
> so here the quote is correct.
>
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: What is the difference between set and setq?

2016-12-28 Thread Bruno Franco
>The same meaning of "eq" (or "quick") have functions like 'delete' /
'delq',
>'assoc' / 'asoq', 'case' / 'casq' or 'push1' / 'push1q'.

Thank you Alex, that was exactly my next question.

On Tue, Dec 27, 2016 at 9:20 AM, Erik Gustafson 
wrote:

> It is the *function* call overhead, which is relatively expensive. [..]
>
>
> Thanks Alex, this is great. I'll add to the wiki article later today.
>
>


Re: What is the difference between set and setq?

2016-12-26 Thread Bruno Franco
This might be a nice thing to add to the documentation too, since the
function definitions don't mention it. Maybe something like: "Its only
difference with set is that setq does not evaluate its first argument"

On Mon, Dec 26, 2016 at 11:26 PM, Bruno Franco <brunofrancosala...@gmail.com
> wrote:

> Thank you so much Erik! I especially like that you said WHY setq is named
> like that. Its been bugging me for weeks!
>
> On Mon, Dec 26, 2016 at 10:25 PM, Erik Gustafson <
> erik.d.gustaf...@gmail.com> wrote:
>
>> Hahaha I read your post quickly and then wrote a possibly overkill answer.
>>
>> I deduce that setq doesn't evaluate its first argument, while set does.
>>> Why is that?
>>>
>>
>> You've totally got it! So the short answer is flexibility vs convience,
>> nothing deeper than that ;)
>>
>> Cheers!
>>
>>
>>
>


Re: What is the difference between set and setq?

2016-12-26 Thread Bruno Franco
Thank you so much Erik! I especially like that you said WHY setq is named
like that. Its been bugging me for weeks!

On Mon, Dec 26, 2016 at 10:25 PM, Erik Gustafson  wrote:

> Hahaha I read your post quickly and then wrote a possibly overkill answer.
>
> I deduce that setq doesn't evaluate its first argument, while set does.
>> Why is that?
>>
>
> You've totally got it! So the short answer is flexibility vs convience,
> nothing deeper than that ;)
>
> Cheers!
>
>
>


What is the difference between set and setq?

2016-12-26 Thread Bruno Franco
I know that they're used to bind a variable to a value, and that they do
behave differently, but I don't understand the principle behind their
difference, and I can't predict how they will behave differently from each
other.

>From this little piece:
: (set B 1)
!? (set B 1)
NIL -- Protected symbol
?
: (setq B 1)
-> 1

I deduce that setq doesn't evaluate its first argument, while set does. Why
is that?

Thank you for your time.


Re: Loosing elements in a sorted list

2016-12-16 Thread Bruno Franco
cool, thanks

On Fri, Dec 16, 2016 at 1:55 PM, Joh-Tob Schäg <johtob...@gmail.com> wrote:

> If they become unreachable, they will be collected.
>
> That is a more compact way ofnsaying what i just said. If you want to get
> more technicalnread mine but this one is easier to understand
> Am 17.12.2016 03:53 schrieb "John Duncan" <duncan.j...@gmail.com>:
>
>> If they become unreachable, they will be collected.
>>
>> On Fri, Dec 16, 2016 at 1:28 PM, Bruno Franco <
>> brunofrancosala...@gmail.com> wrote:
>>
>>> Hi John, Alex,
>>>
>>> Thank you for your explanations, I think I now understand how sort works:
>>> So, for example, in
>>>
>>> : (setq A (3 1 2 4 5 6))
>>> -> (3 1 2 4 5 6)
>>> : (setq B (sort A))
>>> -> (1 2 3 4 5 6)
>>> : A
>>> -> (3 4 5 6)
>>> : B
>>> -> (1 2 3 4 5 6)
>>>
>>> The symbol A points to the first cell of the list (3 1 2 3 4 5 6), and
>>> each cell
>>> points to the next cell in the list. When sort is applied, the pointing
>>> order of the cells
>>> is changed so that each cell is in the right order in the list. But, A
>>> is still pointing to
>>> the same cell as before, and if that cell has moved, then A ends up
>>> pointing to the
>>> middle of the list.
>>>
>>> In the case above, A points to the cell with CAR 3, and when that cell
>>> is moved, A ends
>>> up pointing to the 3rd element of the list. And so, the list that is
>>> built as the value of A
>>> starts at the 3rd element.
>>>
>>> My follow up question is, what happens to those first 2 cells, if
>>> they're not assigned to
>>> anything? Do they just stay there? Or are they deleted, perhaps by the
>>> garbage collector?
>>>
>>> P.S.
>>> I also wanted to apologise. When I reread my first mail I realised it
>>> was arrogant of me to
>>> imply that a feature of the language might be a bug.
>>> You have put a lot of effort into this language, and it shows Several
>>> design decisions that
>>> first surprised me turned out to be awesome, because they let me write
>>> code that was
>>> shorter, easier to read, and prettier. And because they lead to a more
>>> consistent language.
>>>
>>> Thank you for all your effort Alex. I like a lot the language you've
>>> made.
>>>
>>>
>>>
>>> On Thu, Dec 15, 2016 at 8:30 AM, Alexander Burger <a...@software-lab.de>
>>> wrote:
>>>
>>>> Hi Bruno,
>>>>
>>>> > But that might be because with 'by, the operation is not destructive

Loosing elements in a sorted list

2016-12-14 Thread Bruno Franco
Hi list, I have a problem.

Whenever I sort a list stored in a symbol, some elements are erased
from the original list. Look:

: (setq A (3 2 5 4 1 1 1 1 0 1 2 4 5 ))
-> (3 2 5 4 1 1 1 1 0 1 2 4 5)
: (sort A)
-> (0 1 1 1 1 1 2 2 3 4 4 5 5)
: A
-> (3 4 4 5 5)

The pattern that I've noticed is that any element that is smaller than the
CAR of the original list is lost in the sorting.

Its not limited to numbers either:

: (setq A '(a 3 2 5 4 1 1 1 1 0 1 2 4 5 ))
-> (a 3 2 5 4 1 1 1 1 0 1 2 4 5)
: (sort A)
-> (0 1 1 1 1 1 2 2 3 4 4 5 5 a)
: A
-> (a)

If its used with 'by, there is no loss:

: (setq A '(a 3 2 5 4 1 1 1 1 0 1 2 4 5 ))
-> (a 3 2 5 4 1 1 1 1 0 1 2 4 5)
: (by > sort A)
-> (0 1 1 1 1 1 2 2 3 4 4 5 5 a)
: A
-> (a 3 2 5 4 1 1 1 1 0 1 2 4 5)

But that might be because with 'by, the operation is not destructive.

Is this normal operation of picolisp? I assumed its not, because I didn't
catch any reference to it in the documentation.

I'd quite appreciate any help, and if you have any questions let me know.

P.S.
I'm using version 16.6.0, on Ubuntu 16.04


Re: help with list of capital letters as symbol property key

2016-12-14 Thread Bruno Franco
@Alex
I'm surprised that (pick '((A B) (and (= A Value) B)) ListA ListB) is
faster than (get ListB (index Value ListA)).
It's true that get traverses ListB right after a traversal of ListA, but
pick seems to do the same traversal of
the same number of elements. The only difference is that pick traverses the
two lists at the same time, instead
of sequentially.
Why is pick faster?

@dean
How's it going? Did you get what you wanted?

On Tue, Dec 13, 2016 at 3:39 PM, dean  wrote:

> Hi Alex
> I changed those 'Key 'Keys and 'Fn_to_call shortly after posting.
> There'll also be a 3rd list call 'Args.
> Because there are numerous associated bits and pieces they seem a good
> candidate for an object.
> Thank you for "pick" and the above corrections.
> Best Regards
> Dean
>
>
> On 13 December 2016 at 19:58, Alexander Burger 
> wrote:
>
>> Hi Dean,
>>
>> > (setq I '(() (a) (a b)))
>> > (setq V '(empty a_vlu ab_vlu))
>> > (de vlu4key (K 'I 'V)
>>
>> This is fatal! A function needs a list of *symbols*, not expressions like
>> 'I ;)
>>
>> > > (de vlu4key (Vlu 'I 'V)
>> > > (setq Ix (index Vlu I))
>> > > (get V Ix) )
>>
>> Using 'index' to find an element and then traverse the list again with
>> 'get' is
>> not efficient.
>>
>> Instead, I recommend 'pick' where you pass the two lists.
>>
>> Cheers,
>> - Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: T accidentally redefined to NIL

2016-12-10 Thread Bruno Franco
Thanks, I hadn't thought of it. I just tried and it didn't catch the bug
(which as Alex said,
is that I'm calling Mtx as a function, when it isn't). I think its because
the error happens
at runtime, when the data structure Mtx is created, instead of at "compile"
time when
the symbol 'animate is bound to the function definition. From the example
in the
documentation, lint seems to catch only the "compile" time bugs.

On Fri, Dec 9, 2016 at 1:17 AM, Joh-Tob Schäg <johtob...@gmail.com> wrote:

> Did you 'lint the source code? 'lint should warn you when you have T as
> Parameter in a function.
>
> 2016-12-09 5:51 GMT+01:00 Bruno Franco <brunofrancosala...@gmail.com>:
>
>> My my, I see it! Thanks Alex.
>>
>> On Thu, Dec 8, 2016 at 1:50 AM, Alexander Burger <a...@software-lab.de>
>> wrote:
>>
>>> Hi Bruno,
>>>
>>> > I've written something that redefines T to NIL, which surprises me
>>> > because I thought that T was protected from redefinition like that, and
>>> > I have not found a command in the code that looks like it is
>>> redefining T.
>>>
>>> It is true that 'T' is protected from simple, direct modifications like
>>>
>>>: (set T 7)
>>>!? (set T 7)
>>>T -- Protected symbol
>>>
>>> but not from indirect, involved processings. PicoLisp always gives you
>>> enough
>>> power to shoot into your foot ;)
>>>
>>>
>>> > Could you check it out and see if its something in the code, or a bug
>>> in
>>> > the language?
>>>
>>> > # -> Mtx
>>> > (de animate (Mtx) # -> a matrix list (Mtx ..)
>>> > ...
>>> >   (actions (Mtx)) ) )
>>> > # (animate (mtx 4))
>>>
>>> The problem is that you call 'Mtx' as a function in (actions (Mtx)).
>>>
>>> The value of 'Mtx' is not a function
>>>
>>>: (mtx 4)
>>>-> ((T T T T) (NIL NIL NIL NIL) (NIL NIL NIL NIL) (NIL NIL NIL NIL))
>>>
>>> so what you end up doing is calling
>>>
>>>'((T T T T) ...)
>>>
>>> which *looks* like a fuction but is not *meant* to be one. It binds 'T'
>>> as a
>>> formal parameter.
>>>
>>> ♪♫ Alex
>>> --
>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>
>>
>>
>


Re: Why print statement should determine whether I get an error or

2016-12-08 Thread Bruno Franco
Hey Dean,

I think that, in general, you want to quote a sym argument to a function
when
you want to change the value of that symbol. For example:

: (setq A 1)  # Set the value of A to 1
-> 1
: (inc A)   # Evaluate A, *then* pass the result to inc
-> 2
: A
-> 1
: (inc 'A)   # Pass the symbol A to inc
-> 2
: A
-> 2

In (inc A), first A got evaluated to 1, and that 1 was passed to inc, so it
was
the same as (inc 1).
In (inc 'A), the *symbol* A got passed to inc, and inc recognised this and
changed
what A evaluates to.

Another function where this is clear is in pop. It returns the CAR of a
list and, if
given a symbol, it will return the CAR *and* change the value of the symbol.
Here's an example:

: (setq A (1 2 3 4))
-> (1 2 3 4)
: A
-> (1 2 3 4)
: (pop A) # evaluate A, pass that to pop
-> 1
: A
-> (1 2 3 4)
: (pop 'A)# pass the symbol A to pop
-> 1
: A
-> (2 3 4)

Like with inc in the last example, in (pop A) A is evaluated first, to (1 2
3 4),
so what the interpreter sees is (pop (1 2 3 4)).
In contrast, in (pop 'A) the *symbol* A is passed to pop, so the interpreter
both returns the CAR of A, *and *changed the value of the symbol A.

I think that, in general, you want to quote a symbol when you want to change
the value of that symbol when the function is evaluated. I think that not
every
function can do this, and I think it is called "destruction."

set is another function that works differently if the argument is quoted or
not:

: (setq S NIL)
-> NIL
: S
-> NIL
: (set S 1)
!? (set S 1)
NIL -- Protected symbol
? (set 'S 1)
-> 1
? S
-> 1
?
: (set 'S (1 2 3 4))
-> (1 2 3 4)
: S
-> (1 2 3 4)
: (set S 'a)
-> a
: S
-> (a 2 3 4)

When the symbol argument to set is quoted, the value of the symbol is
changed. When it isn't, set expect the argument to be a cons pair (a list),
and changes the value of the CAR of that cons pair, changing the value of
S in the process.

So, if you wanna change what S is using set, quote it.
If S is a list and you wanna change its innards, don't quote it.

This last is actually the part that I understand the least, so if you feel
confused
don't worry: that's probably because I don't know very well what 'm talking
about.

That is more or less all I know.

Here are some functions that behave different if you quote or not their
symbol
argument:
inc, dec, push, pop, set, setq

I recommend you go out and play with them, and if you have any questions,
you'd do us a huge favor by asking them.

P.S.
I'm still new to picolisp, so don't take any of what I say as gospel. And
if anyone
can confirm or expand on what I've said, I'd appreciate it a lot.


On Thu, Dec 8, 2016 at 3:08 PM, Alexander Burger 
wrote:

> Hi Dean,
>
> > I'm used to sprinkling print statements in my code as a way of tracking
> > down bugs but they seem to be affecting my code more than I was
> expecting.
>
> I recommend to look at 'trace' and 'msg'. They both output to stderr and
> don't
> interfer with the expressions.
>
> 'trace' shows what argumments are passed, and what the functions return.
> See the
> tutorial for examples.
>
> 'msg' prints its argument to stderr *and* returns it, so it does not
> destroy the
> flow. For example:
>
>(if (condition)
>   (doTrue)
>   (doFalse1)
>   (doFalse2) )
>
> Now this would be wrong:
>
>(if (condition)
>   (prinl "true")
>   (doTrue)
>   (doFalse1)
>   (doFalse2) )
>
> But this is all right:
>
>(if (msg (condition) " condition")
>   (msg (doTrue) " true")
>   (msm (doFalse1) " false")
>   (doFalse2) )
>
> Even easier is not to modify the source at all, and do instead, before
> starting
> the program
>
>(mapc trace '(condition doTrue doFalse1))
>
> And/or use 'debug' to single-trace your program. Again see the tutorial.
>
>
> > I've also realised I'm never quite sure when and when I shouldn't
> precede a
> > symbol with a quote e.g. as a function argument in a (debug 'Symbol)
> > statement and wonder if there are some very simple rules of thumb.
>
> It is noted in the reference. If an argument is noted as eg. 'any it means
> that
> the argument is *evaluated* (not necessarily that you actually need to
> write a
> quote).
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: T accidentally redefined to NIL

2016-12-08 Thread Bruno Franco
My my, I see it! Thanks Alex.

On Thu, Dec 8, 2016 at 1:50 AM, Alexander Burger 
wrote:

> Hi Bruno,
>
> > I've written something that redefines T to NIL, which surprises me
> > because I thought that T was protected from redefinition like that, and
> > I have not found a command in the code that looks like it is redefining
> T.
>
> It is true that 'T' is protected from simple, direct modifications like
>
>: (set T 7)
>!? (set T 7)
>T -- Protected symbol
>
> but not from indirect, involved processings. PicoLisp always gives you
> enough
> power to shoot into your foot ;)
>
>
> > Could you check it out and see if its something in the code, or a bug in
> > the language?
>
> > # -> Mtx
> > (de animate (Mtx) # -> a matrix list (Mtx ..)
> > ...
> >   (actions (Mtx)) ) )
> > # (animate (mtx 4))
>
> The problem is that you call 'Mtx' as a function in (actions (Mtx)).
>
> The value of 'Mtx' is not a function
>
>: (mtx 4)
>-> ((T T T T) (NIL NIL NIL NIL) (NIL NIL NIL NIL) (NIL NIL NIL NIL))
>
> so what you end up doing is calling
>
>'((T T T T) ...)
>
> which *looks* like a fuction but is not *meant* to be one. It binds 'T' as
> a
> formal parameter.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


T accidentally redefined to NIL

2016-12-07 Thread Bruno Franco
I've written something that redefines T to NIL, which surprises me
because I thought that T was protected from redefinition like that, and
I have not found a command in the code that looks like it is redefining T.

Could you check it out and see if its something in the code, or a bug in
the language?

I'll copy the code here. The examples at the bottom of each function
definition are examples of how to use the function. The comment above
the function tells what it accepts, the comment beside the function name
tells what it returns:

# -> cnt
(de mtx (Size) # -> Mtx
   # Make a seed matrix, of SizexSize
   (cons (need Size T)
  (make
 (do (dec Size)
(link (need Size)) ) ) ) )
# (mtx 4)

# -> Mtx
(de balls (Mtx)   # -> a-list ((y x) ..)
   # Gimme the coordinates of all the balls that can move
   (let (Row 1 Col (length Mtx))
  (make
 (until (= Col 1)
(if (car (nth Mtx Row Col))
   (t
  (link (list Row Col))
  (inc 'Row))
   (dec 'Col) ) ) ) ) )
# (balls (mtx 4))

# -> Mtx, (y x)
(de target (Mtx Ball)   # -> pair (y x)
   # Tell me where I can move the ball.
   (let Col (cadr Ball)
  (for Row (range (car Ball) (length Mtx))
 (NIL (car (nth Mtx Row Col))
(list Row
   (index NIL (car (nth Mtx Row))) ) ) ) ) )
# (target (mtx 4) (car (balls (mtx 4

# -> Mtx, (y x), (y x)
(de fall (Mtx Ball Targ)   # -> Mtx
   # Inside Mtx, move the Ball to Targ-et
   (let Ma (mapcar copy Mtx)
  (set (nth Ma (car Ball) (cadr Ball))
 NIL )
  (set (nth Ma (car Targ) (cadr Targ))
 T )
  Ma ) )
# (let Ba (car (balls (mtx 4))) (fall (mtx 4) Ba (target (mtx 4) Ba)))

# -> Mtx
(de actions (Mtx)# a-list ((y x) ..)
   # All balls and where they fall!
   (mapcar
  '((Ball)
 (list
Ball
(target Mtx Ball) ) )
  (balls Mtx) ) )
# (actions (mtx 4))

# -> Mtx
(de animate (Mtx) # -> a matrix list (Mtx ..)
   (mapcar
  '((Movement)
 (fall Mtx
(car Movement)
(cadr Movement)))
  (actions (Mtx)) ) )
# (animate (mtx 4))

And this is the entire pil + session:

: (load "foo.l")
-> animate
: T
-> T
: (mtx 4)
-> ((T T T T) (NIL NIL NIL NIL) (NIL NIL NIL NIL) (NIL NIL NIL NIL))
: (balls (mtx 4))
-> ((1 4))
: T
-> T
: (target (mtx 4) (car (balls (mtx 4
-> (2 1)
: T
-> T
: (let Ba (car (balls (mtx 4))) (fall (mtx 4) Ba (target (mtx 4) Ba)))
-> ((T T T NIL) (T NIL NIL NIL) (NIL NIL NIL NIL) (NIL NIL NIL NIL))
: T
-> T
: (actions (mtx 4))
-> (((1 4) (2 1)))
: T
-> T
: (animate (mtx 4))
!? (NIL NIL NIL NIL)
NIL -- Undefined
? T
-> NIL
?

As you can see, T is still defined as T up till running 'animate, which
then fails
because T got redefined as NIL.
Also, I'm using ubuntu 16.04 LST, running picolisp version 16.6.0, the 64
bit one.

Thanks a lot for your help. Let me know if I can help in anything.


Copy A to B, so that no change in A affects B

2016-12-04 Thread Bruno Franco
I'm trying to copy a list A in a way that changing the lists inside A don't
affect B.
I've tried using 'copy, like this:

: (setq A '((1 2 3) (4 5 6)))
-> ((1 2 3) (4 5 6))
: (setq B (copy A))
-> ((1 2 3) (4 5 6))

And it works at the top level:
#changing B doesn't change A
: (set B 1)
-> 1
: B
-> (1 (4 5 6))
: A
-> ((1 2 3) (4 5 6))

But, as the documentation says, it works only at the top level of the list:
#changing the CAR of B changes the CAR of A
: (setq B (copy A))
-> ((1 2 3) (4 5 6))
: (set (car B) 'a)
-> a
: B
-> ((a 2 3) (4 5 6))
: A
-> ((a 2 3) (4 5 6))

Is there a function that would copy A so that no changes in any of the
nested lists in A would change B, and vice versa?
Also, as a more general question, is there a name for when two variables
are entangled like this? Where changing one changes the other?


Re: Incomplete documentation on 'need'

2016-12-03 Thread Bruno Franco
I got it! Yes! Thank you Joh. You too Joe, your example helped me a lot!
It really was in the documentation, I just missed it because the opening
paragraph didn't say it explicitly. I guess this is the kind of mistakes
that come from lack of experience.

So, as recap: the 'any argument is the extensor, and it sets what 'lst will
be extended with. And if its not given, it defaults to NIL.

On Sat, Dec 3, 2016 at 7:12 PM, Joe Bogner <joebog...@gmail.com> wrote:

> Hi Bruno, welcome!
>
> I agree the documentation is terse, but I think it's clear.
>
> "When lst is given, it is extended to the left (if cnt is positive) or
> (destructively) to the right (if cnt is negative) with any elements"
>
> Here's an example
>
> Perhaps an additional example would be useful in the docs, but it's
> easy enough to try in the repl
>
> # extend with NIL, same as (need 5)
> : (need 5 '(1 2))
> -> (NIL NIL NIL 1 2)
>
> # extend with a (1 2) with 3 1s
> : (need 5 '(1 2) 1)
> -> (1 1 1 1 2)
>
>
> On Sat, Dec 3, 2016 at 5:59 PM, Joh-Tob Schäg <johtob...@gmail.com> wrote:
> > You are welcome. But from my personal experience the documentation is
> rather
> > terse and changes happen not that often.
> >
> > Also (doc 'need) does state what it does do. Read the last two lines
> `second
> > form`. It is very unclear and i hope Regenaxer takes a look and clarifies
> > it.
> >
> > 2016-12-03 23:41 GMT+01:00 Bruno Franco <brunofrancosala...@gmail.com>:
> >>
> >> Thanks Chri! I'm relieved to hear you say that. I'll make sure to send
> any
> >> question I have.
> >>
> >> On Sat, Dec 3, 2016 at 5:12 PM, Christophe Gragnic
> >> <christophegrag...@gmail.com> wrote:
> >>>
> >>> On Sat, Dec 3, 2016 at 10:54 PM, Bruno Franco
> >>> <brunofrancosala...@gmail.com> wrote:
> >>> > I just wanted to point out that (doc 'need) for version 15.11.0 seems
> >>> > to
> >>> > miss something.
> >>> > […]
> >>> > I also wanted to ask if this kind of topic was appropriate for the
> >>> > mailing
> >>> > list. It seems so small that I wouldn't want to bother everyone just
> to
> >>> > point it out.
> >>>
> >>> I can't say anything about 'need, but I can answer the last question.
> >>> This list is very friendly, especially with newbies.
> >>> You can ask any question or point us to anything.
> >>>
> >>>
> >>> chri
> >>> --
> >>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
> >>
> >>
> >
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Incomplete documentation on 'need'

2016-12-03 Thread Bruno Franco
I just wanted to point out that (doc 'need) for version 15.11.0 seems to
miss something.
It defines the possible arguments of need as:

(need 'cnt ['lst ['any]])

But it doesn't say what the function does with 'any, or how it affects the
result.

I also wanted to ask if this kind of topic was appropriate for the mailing
list. It seems so small that I wouldn't want to bother everyone just to
point it out.


Re: The order of arguments in diff

2016-11-29 Thread Bruno Franco
Wao, the next release?! Thank you! I'm really glad my question could help
that much. I'm looking forward to it!

On Tue, Nov 29, 2016 at 1:18 AM, Alexander Burger <a...@software-lab.de>
wrote:

> On Mon, Nov 28, 2016 at 01:35:30PM -0500, Bruno Franco wrote:
> > So, a better description of diff might be "Returns all the elements in
> the
> > first argument that are not in the second argument"?
>
> Right, very good! I changed it, will be in the next release.
>
> Thanks!
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: The order of arguments in diff

2016-11-28 Thread Bruno Franco
Thanks Alex.
So, a better description of diff might be "Returns all the elements in the
first argument that are not in the second argument"?

On Sun, Nov 27, 2016 at 2:45 AM, Alexander Burger <a...@software-lab.de>
wrote:

> On Sat, Nov 26, 2016 at 09:05:44PM -0500, Bruno Franco wrote:
> > I was trying out the diff function and I noticed something:
> >
> > : (diff '(1 2 3 4) '(3 4))
> > -> (1 2)
> >
> > but
> >
> > : (diff '(3 4) '(1 2 3 4))
> > -> NIL
> >
> > I think this means that there is an order to the arguments of diff, where
>
> It is analogous to the arithmetic difference, where A - B is not the
> same as B - A.
>
>
> > the second argument must be the shortest.
>
> This is not the case. The length is not relevant:
>
>: (diff (1 2 3) (8 6 4 2))
>-> (1 3)
>
>
> > I also tried this:
> >
> > : (diff (1 2 3 4) 2)
> > -> (1 3 4)
> >
> > So, why does diff work even if the second argument isn't a list?
>
> This is a result of how 'diff' is implemented internally. It takes all
> elements into account, I think it is a welcome feature. Note that this
> also works:
>
>: (diff (1 2 3) (1 . 2))
>-> (3)
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


The order of arguments in diff

2016-11-26 Thread Bruno Franco
I was trying out the diff function and I noticed something:

: (diff '(1 2 3 4) '(3 4))
-> (1 2)

but

: (diff '(3 4) '(1 2 3 4))
-> NIL

I think this means that there is an order to the arguments of diff, where
the second argument must be the shortest.
I wanted to ask if this was correct,  and also why was it chosen to be this
way.

I also tried this:

: (diff (1 2 3 4) 2)
-> (1 3 4)

So, why does diff work even if the second argument isn't a list?

I ran (doc 'diff), and though it explained how diff worked, it didn't
answer either of my questions. I'd be grateful for any answers you can give
me, as well as pointers to any document or reference on the internet that
explains these issues.

Thank you very much.


Subscribe

2016-11-25 Thread Bruno Franco
Suscribe