Re: Future of PicoLisp?

2017-02-03 Thread dean
I'll bet most picolisp users are sufficiently motived to compile it but
that means you're probably missing a lot of user's who'd appreciate it if
it was easy to try. As an example I had a right game and failed miserably
on Windows. BTW I'm still working on a response to your questions...In the
meantime

Re multiple entry points are we talking setjmp, longjmp and saving/restoring
ebx esi edi bp sp & pc? I'm looking at this along with stack control.

Re the carry flag...you can easily get at this but do you want change it
too?

Re pb talking to c you have two choices. You can use cdecl and dlls...I
found it easy to with Delphi (stdcall). or because the assembler is masm
compliant...if you wanted to access C functionality from PB you could
reduce the c to asm and PB could include it as PB modules. I have this on
good authority from a leading masm proponent :)

Here are the calling conventions PB supports
http://powerbasic.com/help/pbwin/

Re register allocation...REGISTER *variable* [AS *type*] [, *variable* [AS
*type*]]
The REGISTER statement is used to define certain local variables which are
stored directly in specific CPU registers,



On 3 February 2017 at 17:54, Bruno Franco <brunofrancosala...@gmail.com>
wrote:

> 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 <a...@software-lab.de>
> 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: (NIL) vs Nothing

2017-02-01 Thread dean
Thank you for your insight that contradicts and clarifies numerous of my
misconceptions.
That's exactly what I needed.
Best Regards
Dean


On 1 February 2017 at 08:20, Alexander Burger <a...@software-lab.de> wrote:

> He Dean,
>
> > I've "proved" that a let statement's result is visible ANYWHERE within
> it's
> > bounding parens but not outside of them and
>
> That's right. However, the term "a let statement's result" means something
> different.
>
>(let A 3
>   (* A 4) )
>
> This 'let' statement has the *result* 12. The symbol 'A' is *bound" to the
> result of evaluating the expression '3'. And this binding is valid
> throughout
> the body of the 'let'.
>
>
> > I was hoping to define the scope of X locally by wrapping the lot with
> > (let X some_dummy_value
>
> 'let' does not define the scope of 'X'. 'X' is an internal symbol which has
> always global scope ("scope" means "visibility"). What 'let' does is to
> set up
> the binding, which means saving the current value, assigning a new one, and
> restoring the old value when the 'let' is done.
>
>
> > but binding X to some dummy value casts that value in
> stone...invalidating
>
> This is not true. The value can be changed
>
>(let A 3
>   (setq A (inc (* A 4)))
>   ...
>   A )
>
> This should return 13.
>
>
> Note that 'let' is just a shorthand for 'use' + 'setq':
>
>(let A 3
>   ...
>
> is the same as
>
>(use A
>   (setq A 3)
>   ...
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: (NIL) vs Nothing

2017-01-31 Thread dean
Each one of the "let"s in the following method WAS a setq. All I did was
wrap the existing body with parens and assign Ln and Res with "let" but it
doesn't work. The examples I've seen tend to be like this...
(let X 3

)




)


On 30 January 2017 at 16:19, dean <deangwillia...@gmail.com> wrote:

> Hi Alex
> Yes that worked great preceded by a testi.e. whizzing through all file
> lines in the input file until almost the 4000th which triggered reporting
> on the method of interests's input and output. Thank you very much for the
> advice.
> Best Regards
> Dean
>
> On 30 January 2017 at 11:07, Alexander Burger <a...@software-lab.de> wrote:
>
>> Hi Dean,
>>
>> > trace operates in debug mode but again am not exactly sure how to ensure
>> > that I am in debug mode on a method (rather than a function which is
>> just
>> > (debug 'Fn) at that point.
>> > I have tried but get can't trace.
>>
>> While (trace 'foo) traces a function, (trace 'meth> '+Class) traces a
>> method.
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: (NIL) vs Nothing

2017-01-31 Thread dean
Oops acccidentally sent before I finished...Sorry!

I was going to say the examples I've seen tend to be
(let X 3





   (dm ln_completes> (Ln Ln_no)
  (let (Ln Ln Res 0)
 (if (gt0 (: first_ln_no))
(let Ln (pack " " Ln)))
 (if (<> (: new_buf) NIL)
(=: buf (: new_buf))
(=: buf (: hdngs)))
 (if (member Ln (: buf))
(prog
   (if (gt0 (: first_ln_no))
  (let Res (: first_ln_no))
  (let Res Ln_no))
   (reset> This)
   (let Res Res))
(prog #not a member
   (=: new_buf (fltr_mtchng_hdng_rmndrs Ln))
   (if (<> (: new_buf) NIL)
  (if (=0 (: first_ln_no))
 (=: first_ln_no Ln_no))
  (reset> This))
   (let Res 0)

On 31 January 2017 at 16:27, dean <deangwillia...@gmail.com> wrote:

> Each one of the "let"s in the following method WAS a setq. All I did was
> wrap the existing body with parens and assign Ln and Res with "let" but it
> doesn't work. The examples I've seen tend to be like this...
> (let X 3
>
> )
>
>
>
>
> )
>
>
> On 30 January 2017 at 16:19, dean <deangwillia...@gmail.com> wrote:
>
>> Hi Alex
>> Yes that worked great preceded by a testi.e. whizzing through all
>> file lines in the input file until almost the 4000th which triggered
>> reporting on the method of interests's input and output. Thank you very
>> much for the advice.
>> Best Regards
>> Dean
>>
>> On 30 January 2017 at 11:07, Alexander Burger <a...@software-lab.de>
>> wrote:
>>
>>> Hi Dean,
>>>
>>> > trace operates in debug mode but again am not exactly sure how to
>>> ensure
>>> > that I am in debug mode on a method (rather than a function which is
>>> just
>>> > (debug 'Fn) at that point.
>>> > I have tried but get can't trace.
>>>
>>> While (trace 'foo) traces a function, (trace 'meth> '+Class) traces a
>>> method.
>>>
>>> ♪♫ Alex
>>> --
>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>
>>
>>
>


Re: (NIL) vs Nothing

2017-01-31 Thread dean
Any help advising how I should restructure the parens in order to replace
setq with let would really help me to understand how to do it.
Thank you in anticipation and sorry if this is a really easy thing to do.

On 31 January 2017 at 16:32, dean <deangwillia...@gmail.com> wrote:

> I've inadvertently pressed some send key combo again...
>
> simple use of let is fine e.g.
> (let X 3
>do what ever you want to do with X here without much change of hierachy
> )
>
> Ln doesn't fit this usage pattern and to "let" it be something at the top
> seems somewhat artificial because there's an if statement deciding whether
> to change it's supplied value or not.
>
>
>
> On 31 January 2017 at 16:29, dean <deangwillia...@gmail.com> wrote:
>
>> Oops acccidentally sent before I finished...Sorry!
>>
>> I was going to say the examples I've seen tend to be
>> (let X 3
>>
>>
>>
>>
>>
>>(dm ln_completes> (Ln Ln_no)
>>   (let (Ln Ln Res 0)
>>  (if (gt0 (: first_ln_no))
>> (let Ln (pack " " Ln)))
>>  (if (<> (: new_buf) NIL)
>> (=: buf (: new_buf))
>> (=: buf (: hdngs)))
>>  (if (member Ln (: buf))
>> (prog
>>(if (gt0 (: first_ln_no))
>>   (let Res (: first_ln_no))
>>   (let Res Ln_no))
>>(reset> This)
>>(let Res Res))
>> (prog #not a member
>>(=: new_buf (fltr_mtchng_hdng_rmndrs Ln))
>>(if (<> (: new_buf) NIL)
>>   (if (=0 (: first_ln_no))
>>  (=: first_ln_no Ln_no))
>>   (reset> This))
>>(let Res 0)
>>
>> On 31 January 2017 at 16:27, dean <deangwillia...@gmail.com> wrote:
>>
>>> Each one of the "let"s in the following method WAS a setq. All I did was
>>> wrap the existing body with parens and assign Ln and Res with "let" but it
>>> doesn't work. The examples I've seen tend to be like this...
>>> (let X 3
>>>
>>> )
>>>
>>>
>>>
>>>
>>> )
>>>
>>>
>>> On 30 January 2017 at 16:19, dean <deangwillia...@gmail.com> wrote:
>>>
>>>> Hi Alex
>>>> Yes that worked great preceded by a testi.e. whizzing through all
>>>> file lines in the input file until almost the 4000th which triggered
>>>> reporting on the method of interests's input and output. Thank you very
>>>> much for the advice.
>>>> Best Regards
>>>> Dean
>>>>
>>>> On 30 January 2017 at 11:07, Alexander Burger <a...@software-lab.de>
>>>> wrote:
>>>>
>>>>> Hi Dean,
>>>>>
>>>>> > trace operates in debug mode but again am not exactly sure how to
>>>>> ensure
>>>>> > that I am in debug mode on a method (rather than a function which is
>>>>> just
>>>>> > (debug 'Fn) at that point.
>>>>> > I have tried but get can't trace.
>>>>>
>>>>> While (trace 'foo) traces a function, (trace 'meth> '+Class) traces a
>>>>> method.
>>>>>
>>>>> ♪♫ Alex
>>>>> --
>>>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>>>
>>>>
>>>>
>>>
>>
>


Re: (NIL) vs Nothing

2017-01-31 Thread dean
I've inadvertently pressed some send key combo again...

simple use of let is fine e.g.
(let X 3
   do what ever you want to do with X here without much change of hierachy
)

Ln doesn't fit this usage pattern and to "let" it be something at the top
seems somewhat artificial because there's an if statement deciding whether
to change it's supplied value or not.



On 31 January 2017 at 16:29, dean <deangwillia...@gmail.com> wrote:

> Oops acccidentally sent before I finished...Sorry!
>
> I was going to say the examples I've seen tend to be
> (let X 3
>
>
>
>
>
>(dm ln_completes> (Ln Ln_no)
>   (let (Ln Ln Res 0)
>  (if (gt0 (: first_ln_no))
> (let Ln (pack " " Ln)))
>  (if (<> (: new_buf) NIL)
> (=: buf (: new_buf))
> (=: buf (: hdngs)))
>  (if (member Ln (: buf))
> (prog
>(if (gt0 (: first_ln_no))
>   (let Res (: first_ln_no))
>   (let Res Ln_no))
>(reset> This)
>(let Res Res))
> (prog #not a member
>(=: new_buf (fltr_mtchng_hdng_rmndrs Ln))
>(if (<> (: new_buf) NIL)
>   (if (=0 (: first_ln_no))
>      (=: first_ln_no Ln_no))
>   (reset> This))
>(let Res 0)
>
> On 31 January 2017 at 16:27, dean <deangwillia...@gmail.com> wrote:
>
>> Each one of the "let"s in the following method WAS a setq. All I did was
>> wrap the existing body with parens and assign Ln and Res with "let" but it
>> doesn't work. The examples I've seen tend to be like this...
>> (let X 3
>>
>> )
>>
>>
>>
>>
>> )
>>
>>
>> On 30 January 2017 at 16:19, dean <deangwillia...@gmail.com> wrote:
>>
>>> Hi Alex
>>> Yes that worked great preceded by a testi.e. whizzing through all
>>> file lines in the input file until almost the 4000th which triggered
>>> reporting on the method of interests's input and output. Thank you very
>>> much for the advice.
>>> Best Regards
>>> Dean
>>>
>>> On 30 January 2017 at 11:07, Alexander Burger <a...@software-lab.de>
>>> wrote:
>>>
>>>> Hi Dean,
>>>>
>>>> > trace operates in debug mode but again am not exactly sure how to
>>>> ensure
>>>> > that I am in debug mode on a method (rather than a function which is
>>>> just
>>>> > (debug 'Fn) at that point.
>>>> > I have tried but get can't trace.
>>>>
>>>> While (trace 'foo) traces a function, (trace 'meth> '+Class) traces a
>>>> method.
>>>>
>>>> ♪♫ Alex
>>>> --
>>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>>
>>>
>>>
>>
>


Re: (NIL) vs Nothing

2017-01-31 Thread dean
Here's the original "setq" method

  (dm ln_completes> (Ln Ln_no)
 (if (gt0 (: first_ln_no))
(setq Ln (pack " " Ln)))
 (if (<> (: new_buf) NIL)
(=: buf (: new_buf))
(=: buf (: hdngs)))
 (if (member Ln (: buf))
(prog
   (if (gt0 (: first_ln_no))
  (setq Res (: first_ln_no))
  (setq Res Ln_no))
   (reset> This)
   (setq Res Res))
(prog #not a member
   (=: new_buf (fltr_mtchng_hdng_rmndrs Ln))
   (if (<> (: new_buf) NIL)
  (if (=0 (: first_ln_no))
 (=: first_ln_no Ln_no))
  (reset> This))
   (setq Res 0

On 31 January 2017 at 16:35, dean <deangwillia...@gmail.com> wrote:

> Any help advising how I should restructure the parens in order to replace
> setq with let would really help me to understand how to do it.
> Thank you in anticipation and sorry if this is a really easy thing to do.
>
> On 31 January 2017 at 16:32, dean <deangwillia...@gmail.com> wrote:
>
>> I've inadvertently pressed some send key combo again...
>>
>> simple use of let is fine e.g.
>> (let X 3
>>do what ever you want to do with X here without much change of hierachy
>> )
>>
>> Ln doesn't fit this usage pattern and to "let" it be something at the top
>> seems somewhat artificial because there's an if statement deciding whether
>> to change it's supplied value or not.
>>
>>
>>
>> On 31 January 2017 at 16:29, dean <deangwillia...@gmail.com> wrote:
>>
>>> Oops acccidentally sent before I finished...Sorry!
>>>
>>> I was going to say the examples I've seen tend to be
>>> (let X 3
>>>
>>>
>>>
>>>
>>>
>>>(dm ln_completes> (Ln Ln_no)
>>>   (let (Ln Ln Res 0)
>>>  (if (gt0 (: first_ln_no))
>>> (let Ln (pack " " Ln)))
>>>  (if (<> (: new_buf) NIL)
>>> (=: buf (: new_buf))
>>> (=: buf (: hdngs)))
>>>  (if (member Ln (: buf))
>>> (prog
>>>(if (gt0 (: first_ln_no))
>>>   (let Res (: first_ln_no))
>>>   (let Res Ln_no))
>>>(reset> This)
>>>(let Res Res))
>>> (prog #not a member
>>>(=: new_buf (fltr_mtchng_hdng_rmndrs Ln))
>>>(if (<> (: new_buf) NIL)
>>>   (if (=0 (: first_ln_no))
>>>  (=: first_ln_no Ln_no))
>>>   (reset> This))
>>>(let Res 0)
>>>
>>> On 31 January 2017 at 16:27, dean <deangwillia...@gmail.com> wrote:
>>>
>>>> Each one of the "let"s in the following method WAS a setq. All I did
>>>> was wrap the existing body with parens and assign Ln and Res with "let" but
>>>> it doesn't work. The examples I've seen tend to be like this...
>>>> (let X 3
>>>>
>>>> )
>>>>
>>>>
>>>>
>>>>
>>>> )
>>>>
>>>>
>>>> On 30 January 2017 at 16:19, dean <deangwillia...@gmail.com> wrote:
>>>>
>>>>> Hi Alex
>>>>> Yes that worked great preceded by a testi.e. whizzing through all
>>>>> file lines in the input file until almost the 4000th which triggered
>>>>> reporting on the method of interests's input and output. Thank you very
>>>>> much for the advice.
>>>>> Best Regards
>>>>> Dean
>>>>>
>>>>> On 30 January 2017 at 11:07, Alexander Burger <a...@software-lab.de>
>>>>> wrote:
>>>>>
>>>>>> Hi Dean,
>>>>>>
>>>>>> > trace operates in debug mode but again am not exactly sure how to
>>>>>> ensure
>>>>>> > that I am in debug mode on a method (rather than a function which
>>>>>> is just
>>>>>> > (debug 'Fn) at that point.
>>>>>> > I have tried but get can't trace.
>>>>>>
>>>>>> While (trace 'foo) traces a function, (trace 'meth> '+Class) traces a
>>>>>> method.
>>>>>>
>>>>>> ♪♫ Alex
>>>>>> --
>>>>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>


Re: (NIL) vs Nothing

2017-01-31 Thread dean
> This *might* be what you need. I can't test it.
That's fine.
Your comments are EXTREMELY helpful because as you correctly note I am
struggling with this.
I still don't understand some of things you mention so please bear with me
and I'll try narrow down the source of my misunderstanding.
Thank you for your help and example.
They are very much appreciated.
Best Regards
Dean


On 31 January 2017 at 18:31, Alexander Burger <a...@software-lab.de> wrote:

> On Tue, Jan 31, 2017 at 07:14:57PM +0100, Alexander Burger wrote:
> > The only place where it is good is the line (setq Ln (pack " " Ln)). For
> the
> > rest all 'setq's can be simply omitted if you fix the conditional flow.
> >
> > Try it! :)
>
> OK, could not resist ;)
>
> This *might* be what you need. I can't test it.
>
>(dm ln_completes> (Ln Ln_no)
>   (if (gt0 (: first_ln_no))
>  (setq Ln (pack " " Ln)) )
>   (=: buf (or (: new_buf) (: hdngs)))
>   (if (member Ln (: buf))
>  (prog1
> (if (gt0 (: first_ln_no))
>(: first_ln_no)
>Ln_no )
> (reset> This) )
>  # not a member
>  (=: new_buf (fltr_mtchng_hdng_rmndrs Ln))
>  (if (: new_buf)
> (if (=0 (: first_ln_no))
>(=: first_ln_no Ln_no) )
> (reset> This) )
>  0 ) )
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: replacement for (let L2 (drop L1 2)....

2017-02-07 Thread dean
Wow...really pleased I asked. Those are great examples and I'm sure I'll
learn a lot from them. I've needed to process lists/trees most of
programming "life" and the languages I've used haven't exactly regarded
them as first class citizens and this has slowed me down quite a lot. I
don't have that problem now and despite my lack of familiarity and needing
to look a lot of stuff upthe results are extremely rewarding. Thank you
all for your help and advice.

Best Regards
Dean

On 7 February 2017 at 08:50, Jon Kleiser <jon.klei...@ceres.no> wrote:

> Hi,
>
> I wasn’t aware of nor, nand, nond. Maybe there should have been a few more
> “See also” in the docs.
>
> /Jon
>
> > On 7. Feb, 2017, at 08:31, Alexander Burger <a...@software-lab.de> wrote:
> >
> > On Tue, Feb 07, 2017 at 08:13:06AM +0100, Alexander Burger wrote:
> >> Better to use (not Lst).
> >
> > One more note: I even try to avoid 'not' whenever possible, as it is an
> > additional function call overhead.
> >
> > It is often possible to use the complementary flow function,
> > like (ifn Lst ..) instead of (if (not Lst) ..).
> >
> >   if<->   ifn
> >   and   <->   nor
> >   or<->   nand
> >   when  <->   unless
> >   cond  <->   nond
> >   while <->   until
> >
> > ♪♫ Alex
> > --
>
>


Re: unit testing?

2017-02-08 Thread dean
Hi Alex and Christophe
In Python that __name__ variable stops things like a local main proc from
executing altogether...when Python detects that the module in which it
exists no longer needs it because it is being loaded by a bigger program,
which accesses the module's code like the local main does i.e. The local
main is hidden from Python under such circumstances.

I was wondering about  the "once" situation toobecause I have
experienced "function redeclared" or some such popping up. If you're
telling me that such messages are inconsequential compared to the benefits
of developing in a way which causes that.that's fine by me because it's
easier to ignore the redeclaration messages than not :)

Because PL seems to allow forward referencing...I was
1 Putting all the scaffolding down the bottom with my local main so it's
all in the same place.
2 Commenting it all out...
3 Loading the module into the wider program and then
4 Comment the helper functions back in as PL reported their absence.
Obviously the local main stays commented out.
This seems fairly convenient but my interpretation of the above is I only
need to comment out the local main and if that's right that's great.

Thank you Chrostophe for the further explanation re Python.

Best Regards
Dean






On 8 February 2017 at 14:47, Christophe Gragnic <christophegrag...@gmail.com
> wrote:

> On Wed, Feb 8, 2017 at 12:13 PM, Alexander Burger <a...@software-lab.de>
> wrote:
> >> I'm thinking of Python's `if __name__ == '__main__' and Perl's unless
> >> (caller) {...}
> >
> > I don't know Python and Perl well enough. But perhaps 'once' is what you
> think
> > of?
> >
> >(once (load "xxx.l"))
>
> No, it's different.
>
> In Python there's a «magic» variable named __name__.
> As files can be:
> - imported from another script/module
> - interpreted directly from top leve
> it provides a trick to distinguish between those two ways to use a
> script/module.
> See here:
> https://docs.python.org/3/library/__main__.html
>
>
> chri
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


returning a list of symbols after sorting...not values

2017-02-05 Thread dean
"by".found it :)

: (let (A 1 B 2 C 3) (by val sort '(C A B)))
-> (A B C)


returning a list of symbols after sorting...not values

2017-02-05 Thread dean
I'm sure I've seen an example of this but can't find it.
e.g.
( let (A 1 B 3 C 2)
 (let L1 (list A B C)
 (let L2 (sort L1. but getting A B & C in order not 1 2 3

Any help much appreciated


Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread dean
Oh gosh...I missed that completely...Thanks Lindsay...That explains
everything!
I'm really pleased you told me that because drop looks like a really useful
function.
Best Regards
Dean

On 6 February 2017 at 22:27, Lindsay John Lawrence <
lawrence.lindsayj...@gmail.com> wrote:

> P16 (**) Drop every N’th element from a list.
>
> (de drop (Lst N)
>   (make
> (for (I . X) Lst
>   (unless (=0 (% I N))
>   (link X) ) ) ) )
>
> : (drop ’(a b c d e f g h i k) 3)
> -> (a b d e g h k)
>
> 'drop' is the function given as a solution to the problem.
>
> /Lindsay
>
>
> On Mon, Feb 6, 2017 at 1:24 PM, dean <deangwillia...@gmail.com> wrote:
>
>> Hi Alex
>>: (filter prog2 (1 a 2 b 3 c) '(T NIL .))
>>-> (1 2 3)
>>: (filter prog2 (1 a 2 b 3 c) '(NIL T .))
>>-> (a b c)
>>
>> Yes the above is exactly what I'm after.
>>
>> I copied this drop example straight from ninety nine..
>> ? P16 (**) Drop every N'th element from a list.
>> : (drop '(a b c d e f g h i k) 3)
>> !? (drop '(a b c d e f g h i k) 3)
>> drop -- Undefined
>>
>> I'm not sure why I'm getting "undefined".
>> I'm using the pil in my picolisp directory which looks like this
>> exec ${0%/*}/bin/picolisp ${0%/*}/lib.l @ext.l "$@"
>> i.e. not the one in /bin which contains /usr which I think ISN'T
>> local and I think I compiled a local version.
>>
>> Irrespectivethank you very much for your solution.
>>
>> Best Regards Dean
>>
>>
>> On 6 February 2017 at 15:24, Alexander Burger <a...@software-lab.de>
>> wrote:
>>
>>> On Mon, Feb 06, 2017 at 12:25:14PM +0100, Alexander Burger wrote:
>>> > > I'd like to split a list '(txt1 2 txt2 6
>>> > > into 2 lists
>>> > > '(txt1 txt2...
>>> > > and
>>> > > '(2 6
>>> >
>>> > You could for example filter them:
>>> >
>>> >(let
>>> >   (Lst '(txt1 2 txt2 6)
>>> >  A (filter sym? Lst)
>>> >  B (filter num? Lst) )
>>> >   ... use A and B ...)
>>>
>>> It is not clear what you need.
>>>
>>>
>>> If, for example, you want every *second* element, there is a nice trick:
>>>
>>>: (filter prog2 (1 a 2 b 3 c) '(T NIL .))
>>>-> (1 2 3)
>>>
>>>: (filter prog2 (1 a 2 b 3 c) '(NIL T .))
>>>-> (a b c)
>>>
>>> Similarly, you can extract other sequences if you pass the right pattern
>>> of
>>> NIL's and T's.
>>>
>>> ♪♫ Alex
>>> --
>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>
>>
>>
>


Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread dean
I just came back to say I just looked and didn't realise I had to click P16
to see that function
Thanks once again.
Just goes to show...however idiot-proof you make your system
someone will just invent a better idiot :)

On 6 February 2017 at 22:51, dean <deangwillia...@gmail.com> wrote:

> Oh gosh...I missed that completely...Thanks Lindsay...That explains
> everything!
> I'm really pleased you told me that because drop looks like a really
> useful function.
> Best Regards
> Dean
>
> On 6 February 2017 at 22:27, Lindsay John Lawrence <
> lawrence.lindsayj...@gmail.com> wrote:
>
>> P16 (**) Drop every N’th element from a list.
>>
>> (de drop (Lst N)
>>   (make
>> (for (I . X) Lst
>>   (unless (=0 (% I N))
>>   (link X) ) ) ) )
>>
>> : (drop ’(a b c d e f g h i k) 3)
>> -> (a b d e g h k)
>>
>> 'drop' is the function given as a solution to the problem.
>>
>> /Lindsay
>>
>>
>> On Mon, Feb 6, 2017 at 1:24 PM, dean <deangwillia...@gmail.com> wrote:
>>
>>> Hi Alex
>>>: (filter prog2 (1 a 2 b 3 c) '(T NIL .))
>>>-> (1 2 3)
>>>: (filter prog2 (1 a 2 b 3 c) '(NIL T .))
>>>-> (a b c)
>>>
>>> Yes the above is exactly what I'm after.
>>>
>>> I copied this drop example straight from ninety nine..
>>> ? P16 (**) Drop every N'th element from a list.
>>> : (drop '(a b c d e f g h i k) 3)
>>> !? (drop '(a b c d e f g h i k) 3)
>>> drop -- Undefined
>>>
>>> I'm not sure why I'm getting "undefined".
>>> I'm using the pil in my picolisp directory which looks like this...

Re: replacement for (let L2 (drop L1 2)....

2017-02-06 Thread dean
Hi Alex
   : (filter prog2 (1 a 2 b 3 c) '(T NIL .))
   -> (1 2 3)
   : (filter prog2 (1 a 2 b 3 c) '(NIL T .))
   -> (a b c)

Yes the above is exactly what I'm after.

I copied this drop example straight from ninety nine
? P16 (**) Drop every N'th element from a list.
: (drop '(a b c d e f g h i k) 3)
!? (drop '(a b c d e f g h i k) 3)
drop -- Undefined

I'm not sure why I'm getting "undefined".
I'm using the pil in my picolisp directory which looks like this
exec ${0%/*}/bin/picolisp ${0%/*}/lib.l @ext.l "$@"
i.e. not the one in /bin which contains /usr which I think ISN'T local
and I think I compiled a local version.

Irrespectivethank you very much for your solution.

Best Regards Dean


On 6 February 2017 at 15:24, Alexander Burger <a...@software-lab.de> wrote:

> On Mon, Feb 06, 2017 at 12:25:14PM +0100, Alexander Burger wrote:
> > > I'd like to split a list '(txt1 2 txt2 6
> > > into 2 lists
> > > '(txt1 txt2...
> > > and
> > > '(2 6
> >
> > You could for example filter them:
> >
> >(let
> >   (Lst '(txt1 2 txt2 6)
> >  A (filter sym? Lst)
> >  B (filter num? Lst) )
> >   ... use A and B ...)
>
> It is not clear what you need.
>
>
> If, for example, you want every *second* element, there is a nice trick:
>
>: (filter prog2 (1 a 2 b 3 c) '(T NIL .))
>-> (1 2 3)
>
>: (filter prog2 (1 a 2 b 3 c) '(NIL T .))
>-> (a b c)
>
> Similarly, you can extract other sequences if you pass the right pattern of
> NIL's and T's.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


unit testing?

2017-02-08 Thread dean
When developing non-trivial functions in isolationyou need to copy some
of the supporting scaffolding over from your main program to support it.
When you subsequently come to "load" the module into your main
program...there's a danger of duplicate scaffolding.
Is there some way to hide the copied scaffolding in your module along with
the module's main clause upon loading
or perhaps with the flick of a "switch".
I'm thinking of Python's `if __name__ == '__main__' and Perl's unless
(caller) {...}
Just wondering.


Re: (NIL) vs Nothing

2017-02-04 Thread dean
Thank you very much for the explanation.

On 3 February 2017 at 21:04, pd <eukel...@gmail.com> wrote:

> The reason for this difference is let behaviour:  let binds a symbol to a
> value *inside* let expression but first saves values of binding symbols and
> once evaluated the expression it restores previous symbols values saved.
>
> So, when you wrap a expression in a let binding you are protecting the
> symbols values for further modification, each internal wrapping with let
> gives you a layer of protection.
>
> In first version you protect the expression in a let wrapping, the
> expression (the let body) may change symbols in any way because after being
> evaluated (let's say when exiting let function) the symbol value of symbols
> bound by let will be restored to previus value. But *inside* the clause
> changes happen!
>
> : (let X 0# let binds symbol X to 0 *inside* let
> expression (the following line)
> (for Y 3 (inc 'X) (prinl X))  # in this let expression every change
> to symbol X takes effect, in particular incrementing it
>   )   # after execution of let expression
> binding symbols are restored to saved value (in this case without more
> information it shoud be NIL)
>
> But in second version you add an extra protection layer to the expression
> by wrapping it in a let binding, as always expressions may change symbols
> inside let expression but now they are protected by a internal let layer
> which "hides changing effects"
>
> : (let X 0  # let binds symbol X to 0 *inside* let expression
> (the following lines)
>(for Y 3
>   (let X (inc 'X)   # but now you have an extra let protecction layer
> which binds X thus protecting it for changes made in inner let expression
> by saving current X value (0)
> (prinl X)   # this is inner let expression, prints the value
> of inner X binding (which is always 1 because is always incrementing 0 by 1
> as we will see)
>   ) # at this point let restores value of symbol X to
> previous value , which is 0 as set by outer let binding
>)# so each step of for loop symbol X has value 0
> (because is setted by outer let and restored by inner let) and thus get
> incremeted to 1
>   )
>
> So as you can see let is used to isolate actions without affecting current
> symbol values, you can think of it as "hiding actions"  You can think about
> it in terms of lambda applications which may be easier to understand (if
> you're interested let me know ;-)
>
> As picolisp seem not to have a let* like in classical lisp I assume let
> bindings are done in parallel as traditionally let behaves in classical
> lisp, sure Alex can state it clearly
>
>
> On Thu, Feb 2, 2017 at 7:20 PM, dean <deangwillia...@gmail.com> wrote:
>
>> Just to illustrate what I meant...
>> : (let X 0
>>(for Y 3
>>   (let X (inc 'X) (prinl X
>> 1
>> 1
>> 1
>> -> 1
>>
>> On 2 February 2017 at 18:16, dean <deangwillia...@gmail.com> wrote:
>>
>>> Thank you very much for the adviceI've just used that and it's
>>> worked a treat
>>>
>>> : (let X 0
>>>   (for Y 3
>>>  (inc 'X) (prinl X)))
>>> 1
>>> 2
>>> 3
>>> -> 3
>>>
>>
>
> --
> Andrés
>
> *~ La mejor manera de librarse de la tentación es caer en ella**. ~ Oscar
> Wilde* ~
>


Re: (NIL) vs Nothing

2017-02-04 Thread dean
Thank you for your further explanation


On 4 February 2017 at 08:29, Alexander Burger  wrote:

> On Fri, Feb 03, 2017 at 10:04:02PM +0100, pd wrote:
> > The reason for this difference is let behaviour:  let binds a symbol to a
> > value *inside* let expression but first saves values of binding symbols
> and
> > once evaluated the expression it restores previous symbols values saved

Re: Future of PicoLisp?

2017-02-04 Thread dean
Hi Alex...

re multiple entry points...assuming that means setjmp and longjmp which
save and preserve those registers above (albeit the 16 bit ones SP & BP as
their 32bit equivalents) I've just looked at the code for setjmp and
longjmp and in they're in asm anyway and look fairly innocuous

http://www.jbox.dk/sanos/source/lib/setjmp.c.html
so...I see no reason why they can't be replicated in Powerbasic along with
the save record. (There is a link to the assembler INSIDE the last link of
this post)

I did notice mention of signals in the source code and here's a discussion
re signalling threads in PB

https://forum.powerbasic.com/forum/user-to-user-discussions/programming/62044-what-is-the-best-way-to-signal-a-thread

<https://forum.powerbasic.com/forum/user-to-user-discussions/programming/62044-what-is-the-best-way-to-signal-a-thread>

Stack control was an eye opener i.e. in addition to the meta statement

#STACK num_exprSet the maximum potential stack size.

here's a link re stack overhead reduction with some additional links
further down that expand on the subject.

http://www.powerbasic.com/help/pbcc/stack_overhead_reduction.htm
Best Regards
Dean


On 3 February 2017 at 18:41, Terry Palfrey <terrypalfrey...@gmail.com>
wrote:

> Anyone ever tried the newLISPonRockets.com install? I don't know if
> that will give you ideas for a one touch install.
>
> On Fri, Feb 3, 2017 at 10:10 AM, František Fuka <f...@fuxoft.cz> wrote:
>
>> I think that "adding PPA repository to my system" is not much easier than
>> "downloading Picolisp source and compiling it". You and I can do both.
>> Unskilled users will struggle with both. We need a method for unskilled
>> users that allows them just to download a file, click something, maybe type
>> a line or two --- and have a fully working Picolisp installation as a
>> result. The question of self-updating installed Picolisp (the advantage PPA
>> has over self-compiling) is not relevant for theses users, IMHO.
>>
>> On Fri, Feb 3, 2017 at 6:54 PM, Bruno Franco <
>> brunofrancosala...@gmail.com> wrote:
>>
>>> 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 <a...@software-lab.de>
>>> 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
>>>>
>>>
>>>
>>
>>
>> --
>> *-- Frantisek Fuka*
>> (yes, that IS my real name)
>>
>> -- My Personal homepage: www.fuxoft.cz
>> -- My Google+ profile: google.com/+fuxoft
>> -- My Telegram chat: telegram.fuxoft.cz
>>
>>
>>
>


Re: Future of PicoLisp?

2017-02-04 Thread dean
Oops our threads have crossed.
Sorry about that.
I'll read what you've said now.

On 4 February 2017 at 08:47, dean <deangwillia...@gmail.com> wrote:

> Hi Alex...
>
> re multiple entry points...assuming that means setjmp and longjmp which
> save and preserve those registers above (albeit the 16 bit ones SP & BP as
> their 32bit equivalents) I've just looked at the code for setjmp and
> longjmp and in they're in asm anyway and look fairly innocuous
>
> http://www.jbox.dk/sanos/source/lib/setjmp.c.html
> so...I see no reason why they can't be replicated in Powerbasic along with
> the save record. (There is a link to the assembler INSIDE the last link of
> this post)
>
> I did notice mention of signals in the source code and here's a discussion
> re signalling threads in PB
>
> https://forum.powerbasic.com/forum/user-to-user-
> discussions/programming/62044-what-is-the-best-way-to-signal-a-thread
>
>
> <https://forum.powerbasic.com/forum/user-to-user-discussions/programming/62044-what-is-the-best-way-to-signal-a-thread>
>
> Stack control was an eye opener i.e. in addition to the meta statement
>
> #STACK num_exprSet the maximum potential stack size.
>
> here's a link re stack overhead reduction with some additional links
> further down that expand on the subject.
>
> http://www.powerbasic.com/help/pbcc/stack_overhead_reduction.htm
> Best Regards
> Dean
>
>
> On 3 February 2017 at 18:41, Terry Palfrey <terrypalfrey...@gmail.com>
> wrote:
>
>> Anyone ever tried the newLISPonRockets.com install? I don't know if
>> that will give you ideas for a one touch install.
>>
>> On Fri, Feb 3, 2017 at 10:10 AM, František Fuka <f...@fuxoft.cz> wrote:
>>
>>> I think that "adding PPA repository to my system" is not much easier
>>> than "downloading Picolisp source and compiling it". You and I can do both.
>>> Unskilled users will struggle with both. We need a method for unskilled
>>> users that allows them just to download a file, click something, maybe type
>>> a line or two --- and have a fully working Picolisp installation as a
>>> result. The question of self-updating installed Picolisp (the advantage PPA
>>> has over self-compiling) is not relevant for theses users, IMHO.
>>>
>>> On Fri, Feb 3, 2017 at 6:54 PM, Bruno Franco <
>>> brunofrancosala...@gmail.com> wrote:
>>>
>>>> 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 <a...@software-lab.de>
>>>> 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 assemble

Re: Future of PicoLisp?

2017-02-04 Thread dean
Hi Alex

>No, I want a *generic way* to call existing external libraries, e.g.

Powerbasic won't do what (native... does because it doesn't do variadic
arguments like lisp or even c...

Here's an example .

BTW Important words are LoadLibrary  GetProcAddress Call DWORD FreeLibrary
and recently

IMPORT ADDR

What native does looks very cool

'Declare function prototype
Declare Function protoFreeCCSDLL (Key as ASCIIZ,Param as ASCIIZ) as LONG

Function ProcessCreditCards() as LONG
Local x as LONG
Local hLib as LONG
Local ProcAddr as DWORD
local lResult as LONG

'Retrieve DLL handle
hLib = LoadLibrary("FREECCS.DLL")
If IsFalse hLib Then
MsgBox "FreeCCS.DLL is missing or damaged, please verify
installation", %MB_ICONSTOP,"CCS"
Exit Function
End If

'Retrieve function address
ProcAddr = GetProcAddress(hLib,"FreeCCSDLL")
If ProcAddr = %NULL Then
MsgBox "Could not find function FreeCCSDLL in FreeCCS.DLL"
Exit Function
End If

Key = "MyKey"
Param = "MyParam"

'Call pointer to the function using Function prototype
Call DWORD ProcAddr USING protoFreeCCSDLL(Key,Param) TO lResult

'Do some more calls/processing

'Release Library
Call FreeLibrary(hLib)

Function = lResult
End Function



On 4 February 2017 at 20:26, dean <deangwillia...@gmail.com> wrote:

> Re the carry flag...you can get at that :)
>
> On 4 February 2017 at 20:24, dean <deangwillia...@gmail.com> wrote:
>
>> Hi Alex
>>
>> With stack control I mean that you can do unlimited 'push'es and 'pop's
>> to/from
>> the stack inside a function, and build arbitrary structures this way on
>> the
>> stack. You can add, subtract, increment and decrement the stack pointer
>> arbitrarily, and switch between different stacks by assigning values to
>> the
>> stack pointer.
>>
>> I've read these and it looks like it i.e. you can save and restore EBP
>> and ESP
>> freeing you to do what you want with them until restoration
>> also you can push stuff of one size and pop it off in different sized
>> chunks.
>> It all looks very freestyle to me as long as you balance the stack when
>> you've finished.
>> I'd be very happy to try an example if you want.
>> https://www.powerbasic.com/help/pbcc/the_stack.htm
>> https://www.powerbasic.com/help/pbcc/using_esp_and_ebp.htm
>> https://www.powerbasic.com/help/pbcc/tricks_of_the_stack.htm
>>
>> On 4 February 2017 at 19:32, Lindsay John Lawrence <
>> lawrence.lindsayj...@gmail.com> wrote:
>>
>>> I also run PicoLisp out of a TinyCore Linux 'VirtualBox' image...
>>> This turned out to be the best route for me to get the performance and
>>> features of picolisp I wanted on microsoft windows hosts.
>>>
>>> TinyCore64 + vboxsf (to access host drives) + picolisp is a great combo
>>> in < 50Mb
>>> Exporting that as an 'appliance'  < 15Mb.
>>> == full linux kernel with all the goodness that provides + picolisp
>>> awesomeness to easily utilize all that goodness.
>>>
>>> A slightly larger image with docs+w3m+vim (or the picollsp 'vi'
>>> Alexander published) may make a nicely focused little 'lisp machine'  to
>>> learn and tinker on.
>>>
>>> /Lindsay
>>>
>>>
>>> On Sat, Feb 4, 2017 at 8:40 AM, Erik Gustafson <
>>> erik.d.gustaf...@gmail.com> wrote:
>>>
>>>> Hi list,
>>>>
>>>> Sounds like it's time to update the 'apt-get yourself some PicoLisp'
>>>> section on the wiki, as this is no longer the best route for those new to
>>>> the language.
>>>>
>>>> To confirm, the best options seem to be:
>>>>
>>>> - pil64 for Android
>>>> - Ersatz for Windows
>>>> - Docker Image (Packaged PL + Tiny Core)
>>>> - Build from source
>>>>
>>>> Please add if I'm missing anything.
>>>>
>>>> Now as far as trying PicoLisp goes, could we make a little app like
>>>> http://www.tryclj.com? A sandboxed subset of PL where one could try
>>>> out the language and maybe work through a short accompanying tutorial to
>>>> give a taste of the language, before diving into the install process. I
>>>> think this has been discussed before...?
>>>>
>>>> Also isn't there the Emulisp (PL in JS) REPL app? Could that be
>>>> leveraged? Maybe this is a solution without a problem; I agree with others
>>>> that most people discovering PL will likely be comfortable building from
>>>> source, spinning up a VM, etc
>>>>
>>>> Finally, a side note: I recently came across https://antergos.com.
>>>> It's basically a graphical installer for Arch Linux. I gave it a try and
>>>> found it to be as easy as installing Ubuntu... Click through the install
>>>> wizard and ten minutes later you've got a full-blown Arch desktop
>>>> environment (or base-install if desired) with built-in access to the AUR
>>>> The AUR has always been up to date (many thanks!) with the latest PicoLisp.
>>>> Might be worth a mention?
>>>>
>>>> Erik
>>>>
>>>
>>>
>>
>


Re: Future of PicoLisp?

2017-02-04 Thread dean
Hi Alex

This is not helpful. I want to define registers *globally", so that values,
arguments and return values can be passed between functions. All functions
get
arguments in 1, 2, or more registers, and *return* values (not just a single
value!) in 1, 2 or more registers, plus direct condition codes.
A Fastproc lets you pass up to 3 registers-worth of arguments to it...Any
more and you'd associate the registers with structures to squeeze more in
like this.

https://forum.powerbasic.com/forum/user-to-user-discussions/powerbasic-inline-assembler/744566-fastcall-using-a-structure-for-arguments
which saves you using the stack but not quite as fast as the value sitting
their in the register.

Hope that helps and no problem if this is not of interest...I just saw it
as a way of overcoming CLANG problems re pil32.

Best Regards
Dean




On 4 February 2017 at 20:46, dean <deangwillia...@gmail.com> wrote:

> Hi Alex
>
> >No, I want a *generic way* to call existing external libraries, e.g.
>
> Powerbasic won't do what (native... does because it doesn't do variadic
> arguments like lisp or even c...
>
> Here's an example .
>
> BTW Important words are LoadLibrary  GetProcAddress Call DWORD FreeLibrary
> and recently
>
> IMPORT ADDR
>
> What native does looks very cool
>
> 'Declare function prototype
> Declare Function protoFreeCCSDLL (Key as ASCIIZ,Param as ASCIIZ) as LONG
>
> Function ProcessCreditCards() as LONG
> Local x as LONG
> Local hLib as LONG
> Local ProcAddr as DWORD
> local lResult as LONG
>
> 'Retrieve DLL handle
> hLib = LoadLibrary("FREECCS.DLL")
> If IsFalse hLib Then
> MsgBox "FreeCCS.DLL is missing or damaged, please verify 
> installation", %MB_ICONSTOP,"CCS"
> Exit Function
> End If
>
> 'Retrieve function address
> ProcAddr = GetProcAddress(hLib,"FreeCCSDLL")
> If ProcAddr = %NULL Then
> MsgBox "Could not find function FreeCCSDLL in FreeCCS.DLL"
> Exit Function
> End If
>
> Key = "MyKey"
> Param = "MyParam"
>
> 'Call pointer to the function using Function prototype
> Call DWORD ProcAddr USING protoFreeCCSDLL(Key,Param) TO lResult
>
> 'Do some more calls/processing
>
> 'Release Library
> Call FreeLibrary(hLib)
>
> Function = lResult
> End Function
>
>
>
> On 4 February 2017 at 20:26, dean <deangwillia...@gmail.com> wrote:
>
>> Re the carry flag...you can get at that :)
>>
>> On 4 February 2017 at 20:24, dean <deangwillia...@gmail.com> wrote:
>>
>>> Hi Alex
>>>
>>> With stack control I mean that you can do unlimited 'push'es and 'pop's
>>> to/from
>>> the stack inside a function, and build arbitrary structures this way on
>>> the
>>> stack. You can add, subtract, increment and decrement the stack pointer
>>> arbitrarily, and switch between different stacks by assigning values to
>>> the
>>> stack pointer.
>>>
>>> I've read these and it looks like it i.e. you can save and restore EBP
>>> and ESP
>>> freeing you to do what you want with them until restoration
>>> also you can push stuff of one size and pop it off in different sized
>>> chunks.
>>> It all looks very freestyle to me as long as you balance the stack when
>>> you've finished.
>>> I'd be very happy to try an example if you want.
>>> https://www.powerbasic.com/help/pbcc/the_stack.htm
>>> https://www.powerbasic.com/help/pbcc/using_esp_and_ebp.htm
>>> https://www.powerbasic.com/help/pbcc/tricks_of_the_stack.htm
>>>
>>> On 4 February 2017 at 19:32, Lindsay John Lawrence <
>>> lawrence.lindsayj...@gmail.com> wrote:
>>>
>>>> I also run PicoLisp out of a TinyCore Linux 'VirtualBox' image...
>>>> This turned out to be the best route for me to get the performance and
>>>> features of picolisp I wanted on microsoft windows hosts.
>>>>
>>>> TinyCore64 + vboxsf (to access host drives) + picolisp is a great combo
>>>> in < 50Mb
>>>> Exporting that as an 'appliance'  < 15Mb.
>>>> == full linux kernel with all the goodness that provides + picolisp
>>>> awesomeness to easily utilize all that goodness.
>>>>
>>>> A slightly larger image with docs+w3m+vim (or the picollsp 'vi'
>>>> Alexander published) may make a nicely focused little 'lisp machine'  to
>>>> learn and tinker on.
>>>>
>>>> /Lindsay
>>>>
>>

Re: Future of PicoLisp?

2017-02-04 Thread dean
Hi Alex

With stack control I mean that you can do unlimited 'push'es and 'pop's
to/from
the stack inside a function, and build arbitrary structures this way on the
stack. You can add, subtract, increment and decrement the stack pointer
arbitrarily, and switch between different stacks by assigning values to the
stack pointer.

I've read these and it looks like it i.e. you can save and restore EBP and
ESP
freeing you to do what you want with them until restoration
also you can push stuff of one size and pop it off in different sized
chunks.
It all looks very freestyle to me as long as you balance the stack when
you've finished.
I'd be very happy to try an example if you want.
https://www.powerbasic.com/help/pbcc/the_stack.htm
https://www.powerbasic.com/help/pbcc/using_esp_and_ebp.htm
https://www.powerbasic.com/help/pbcc/tricks_of_the_stack.htm

On 4 February 2017 at 19:32, Lindsay John Lawrence <
lawrence.lindsayj...@gmail.com> wrote:

> I also run PicoLisp out of a TinyCore Linux 'VirtualBox' image...
> This turned out to be the best route for me to get the performance and
> features of picolisp I wanted on microsoft windows hosts.
>
> TinyCore64 + vboxsf (to access host drives) + picolisp is a great combo in
> < 50Mb
> Exporting that as an 'appliance'  < 15Mb.
> == full linux kernel with all the goodness that provides + picolisp
> awesomeness to easily utilize all that goodness.
>
> A slightly larger image with docs+w3m+vim (or the picollsp 'vi' Alexander
> published) may make a nicely focused little 'lisp machine'  to learn and
> tinker on.
>
> /Lindsay
>
>
> On Sat, Feb 4, 2017 at 8:40 AM, Erik Gustafson  > wrote:
>
>> Hi list,
>>
>> Sounds like it's time to update the 'apt-get yourself some PicoLisp'
>> section on the wiki, as this is no longer the best route for those new to
>> the language.
>>
>> To confirm, the best options seem to be:
>>
>> - pil64 for Android
>> - Ersatz for Windows
>> - Docker Image (Packaged PL + Tiny Core)
>> - Build from source
>>
>> Please add if I'm missing anything.
>>
>> Now as far as trying PicoLisp goes, could we make a little app like
>> http://www.tryclj.com? A sandboxed subset of PL where one could try out
>> the language and maybe work through a short accompanying tutorial to give a
>> taste of the language, before diving into the install process. I think this
>> has been discussed before...?
>>
>> Also isn't there the Emulisp (PL in JS) REPL app? Could that be
>> leveraged? Maybe this is a solution without a problem; I agree with others
>> that most people discovering PL will likely be comfortable building from
>> source, spinning up a VM, etc
>>
>> Finally, a side note: I recently came across https://antergos.com. It's
>> basically a graphical installer for Arch Linux. I gave it a try and found
>> it to be as easy as installing Ubuntu... Click through the install wizard
>> and ten minutes later you've got a full-blown Arch desktop environment (or
>> base-install if desired) with built-in access to the AUR The AUR has always
>> been up to date (many thanks!) with the latest PicoLisp. Might be worth a
>> mention?
>>
>> Erik
>>
>
>


replacement for (let L2 (drop L1 2)....

2017-02-06 Thread dean
Hi
I'd like to split a list '(txt1 2 txt2 6
into 2 lists
'(txt1 txt2...
and
'(2 6

I found drop (in ninety nine...) which looks ideal but it's apparently
undefined in pil64.
I've looked for something similar but it's not jumping out :)
Any help much appreciated.


Re: Future of PicoLisp?

2017-02-03 Thread dean
The above addresses only your pil32 problem. I had no idea re pil64 on
Android so glad you sorted it :)

On 3 February 2017 at 13:06, dean <deangwillia...@gmail.com> wrote:

> >the future of PicoLisp is dark.
> That sounds about right...I run openbsd and they've just made v6.0
> Linux- incompatible because they don't like the way it's going.
> Pil64 compiles fine on the latest openbsd BTW.
>
> 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
> your linux exposure but Linux is only 2% of the desktop market whilst
> Windows has about 80%,
>
> 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. It also runs on win95 to 10
> and produces exes for the same, both without any dependencies. How about
> that for stable. It also has very fast dynamic arrays.
>
> 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.
>
>
> On 3 February 2017 at 08:41, Lindsay John Lawrence <
> lawrence.lindsayj...@gmail.com> wrote:
>
>> I hope it is not dark.
>> I am just starting on my adventure using PicoLisp and having a wonderful
>> time of it.
>>
>> Having said that, I have never used any of the distribution packages.
>> Picolisp is simple to compile with minimal dependencies. Thank you for
>> that as well Alex.
>>
>> On my laptop machine I have just been compiling the latest download
>> whenever it is available.
>> It also runs extremely well in a minimal TinyCore Linux  image.
>> Tinycore+Picolisp+core system utils makes for a great sandbox in a few
>> tens of megabytes as either a virtualbox or as a bootable stick
>>
>> I think I also compiled it on Android a few months ago (in Termux)
>> without issue. I'll have to try it again there.
>>
>> Keep the light on :)
>>
>> /Lindsay
>>
>>
>>
>>
>>
>>
>> On Thu, Feb 2, 2017 at 11:47 PM, Alexander Burger <a...@software-lab.de>
>> wrote:
>>
>>> Hi all,
>>>
>>> the future of PicoLisp is dark. I'm not sure if it can survive in
>>> packaged
>>> distribution.
>>>
>>> Ubuntu doesn't support it any more, probably due to the PIE (position
>>> independent executable) on x86-64.
>>>
>>> And at least on Android they seem to demand switching to Clang. The
>>> 32-bit
>>> versions of PicoLisp (pil32 and mini) which are written in C cannot be
>>> compiled
>>> on Clang, because Clang doesn't support dynamically allocated arrays,
>>> which
>>> pil32 depends on. As far as I notices, pil64 also has trouble on
>>> Clang/Android.
>>>
>>> :( Alex
>>> --
>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>
>>
>>
>


Re: (NIL) vs Nothing

2017-02-02 Thread dean
Thank you very much for the adviceI've just used that and it's worked a
treat

: (let X 0
  (for Y 3
 (inc 'X) (prinl X)))
1
2
3
-> 3
I did try my first example with lets instead of setqs but the second let
kept looking at the first let value precluding any
incrementation...ELIMINATING the second let and using just inc inc as you
advised removes the problem by allowing just one let at the top which
works great.

Perhaps inc contains an inc somewhere otherwise how does X actually get
changed but if it does...it doesn't look to be in a place that interferes
with the first let.

Irrespective...you've provided a very elegant solution to my problem and I
thank you for it!

On 2 February 2017 at 17:24, pd <eukel...@gmail.com> wrote:

> I think this is not the use you intent
>
> In *my* opinion:
>
> On Thu, Feb 2, 2017 at 3:44 PM, dean <deangwilliam30@gmailcom
> <deangwillia...@gmail.com>> wrote:
>
>>
>>(setq Ln_no 0)
>>(in Epic_txt_fl_pth
>>   (until (eof)
>>  (setq Ln_no (inc 'Ln_no) )
>>
>
> this is redudant since you're simply incrementing the value of a global
> symbol, simply write:   (inc 'Ln_no)
>
>
>>  (prog
>> ​
>>
>
> As a general not too exact rule setq creates global value while let
> creates a local value
>
> More exactly setq (and set) binds a symbol to a value in the "global
> context" while let binds a symbol to a value only inside the let expression
>
>


Re: (NIL) vs Nothing

2017-02-02 Thread dean
Just to illustrate what I meant...
: (let X 0
   (for Y 3
  (let X (inc 'X) (prinl X
1
1
1
-> 1

On 2 February 2017 at 18:16, dean <deangwillia...@gmail.com> wrote:

> Thank you very much for the adviceI've just used that and it's worked
> a treat
>
> : (let X 0
>   (for Y 3
>  (inc 'X) (prinl X)))
> 1
> 2
> 3
> -> 3
> I did try my first example with lets instead of setqs but the second let
> kept looking at the first let value precluding any
> incrementation...ELIMINATING the second let and using just inc inc as you
> advised removes the problem by allowing just one let at the top which
> works great.
>
> Perhaps inc contains an inc somewhere otherwise how does X actually get
> changed but if it does...it doesn't look to be in a place that interferes
> with the first let.
>
> Irrespective...you've provided a very elegant solution to my problem and I
> thank you for it!
>
> On 2 February 2017 at 17:24, pd <eukel...@gmail.com> wrote:
>
>> I think this is not the use you intent
>>
>> In *my* opinion:
>>
>> On Thu, Feb 2, 2017 at 3:44 PM, dean <deangwilliam30@gmailcom
>> <deangwillia...@gmail.com>> wrote:
>>
>>>
>>>(setq Ln_no 0)
>>>(in Epic_txt_fl_pth
>>>   (until (eof)
>>>  (setq Ln_no (inc 'Ln_no) )
>>>
>>
>> this is redudant since you're simply incrementing the value of a global
>> symbol, simply write:   (inc 'Ln_no)
>>
>>
>>>  (prog
>>> ​
>>>
>>
>> As a general not too exact rule setq creates global value while let
>> creates a local value
>>
>> More exactly setq (and set) binds a symbol to a value in the "global
>> context" while let binds a symbol to a value only inside the let expression
>>
>>
>


Re: (NIL) vs Nothing

2017-01-31 Thread dean
After playing around with some test programs ...I think I've got most of
that now.
I've "proved" that a let statement's result is visible ANYWHERE within it's
bounding parens but not outside of them and

If we have
(do something to X)
(do something to Y)
(do something to X again)

I was hoping to define the scope of X locally by wrapping the lot with
(let X some_dummy_value

   the above 3 statements

)

but binding X to some dummy value casts that value in stone...invalidating
the thing altogether because you only get one go at assigning the value so
it's got to be the "proper" value which you might not know at new contrived
level I was hoping to introduce.

Is that right?

 I didn't know about if (: some_member)or that I could just end a
function/method with e.g.

(if (gt0 (: first_ln_no))
   (: first_ln_no)
   Ln_no )

but really like this short and to the point syntax.

Again...thank you very muchI feel I've learnt a lot today.
Best Regards
Dean






On 31 January 2017 at 19:30, dean <deangwillia...@gmail.com> wrote:

> BTW
> > This *might* be what you need. I can't test it.
> Yes...it works perfectly!
>
> On 31 January 2017 at 19:15, dean <deangwillia...@gmail.com> wrote:
>
>> > This *might* be what you need. I can't test it.
>> That's fine.
>> Your comments are EXTREMELY helpful because as you correctly note I am
>> struggling with this.
>> I still don't understand some of things you mention so please bear with
>> me and I'll try narrow down the source of my misunderstanding.
>> Thank you for your help and example.
>> They are very much appreciated.
>> Best Regards
>> Dean
>>
>>
>> On 31 January 2017 at 18:31, Alexander Burger <a...@software-lab.de>
>> wrote:
>>
>>> On Tue, Jan 31, 2017 at 07:14:57PM +0100, Alexander Burger wrote:
>>> > The only place where it is good is the line (setq Ln (pack " " Ln)).
>>> For the
>>> > rest all 'setq's can be simply omitted if you fix the conditional flow.
>>> >
>>> > Try it! :)
>>>
>>> OK, could not resist ;)
>>>
>>> This *might* be what you need. I can't test it.
>>>
>>>(dm ln_completes> (Ln Ln_no)
>>>   (if (gt0 (: first_ln_no))
>>>  (setq Ln (pack " " Ln)) )
>>>   (=: buf (or (: new_buf) (: hdngs)))
>>>   (if (member Ln (: buf))
>>>  (prog1
>>> (if (gt0 (: first_ln_no))
>>>(: first_ln_no)
>>>Ln_no )
>>> (reset> This) )
>>>  # not a member
>>>  (=: new_buf (fltr_mtchng_hdng_rmndrs Ln))
>>>  (if (: new_buf)
>>> (if (=0 (: first_ln_no))
>>>(=: first_ln_no Ln_no) )
>>> (reset> This) )
>>>  0 ) )
>>>
>>> ♪♫ Alex
>>> --
>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>
>>
>>
>


Re: executing a function + argument passed in as an argument to

2017-01-21 Thread dean
>Yes, you should really try to understand Lisp's evaluation mechanisms.
I agree.

(eval Lst) and apply look just the job for this...Thank you for these.

Best Regards
Dean

On 20 January 2017 at 20:57, Alexander Burger <a...@software-lab.de> wrote:

> On Fri, Jan 20, 2017 at 07:20:36PM +, dean wrote:
> > I just came back to say that the above worked well for both strings and
> > numbers entered directly as the passed functions argument but not (it
> seems
> > :) ) for when the argument is supplied in a symbol. eval might well cope
> > with that and if not...I'll work on it.
>
> Yes, you should really try to understand Lisp's evaluation mechanisms.
>
> (eval Lst) evaluates the normal way, thus evaluating the elements of the
> list in
> turn.
>
> You might also consider 'apply', which passes the elements of a list to a
> function without evaluating them again. This would be in your case
>
>(apply (car Lst) (cdr Lst))
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: dealing with bad input ']' when reading and printing lines in a

2017-01-24 Thread dean
Hi Alex
> What do you want to do?
I was reading each line in an input file text file, trimming it and seeing
if it was a member of a list that I'd created. If it was I was recording
the list type and the number of the line in the file.

Some of the files split their strings (that match the list elements) over
multiple lines making things a bit more involved than (if (member Ln List)
now but I'm not sure that's significant to this problem.

Thank you for asking and best regards
Dean






On 24 January 2017 at 12:14, Alexander Burger <a...@software-lab.de> wrote:

> Hi Dean,
>
> > (de main (Pth)
> >(in Pth (until (eof)
> >   (setq Rec (str (line T)))
> > ...
> > The above is giving me Bad input ']'
> > I wrongly thought str would cope with this
>
> I believe that 'str' is most probably not what you need. It is a rather
> specialized parser, and normally not used.
>
> What do you want to do?
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: dealing with bad input ']' when reading and printing lines in a

2017-01-24 Thread dean
Hi Alex
Thank you for your example and further guidance. I'll look into all of
those suggestions.
Best Regards
Dean

On 24 January 2017 at 17:02, Alexander Burger <a...@software-lab.de> wrote:

> Hi Dean,
>
> > I was reading each line in an input file text file, trimming it and
> seeing
> > if it was a member of a list that I'd created. If it was I was recording
> > the list type and the number of the line in the file.
>
> OK, good. So 'str' is not useful here. 'str' tries to parse a Lisp
> expression
> from the string, possibly giving errors if it is not legal Lisp syntax.
>
> Better to operate directly on (sub)strings perhaps, e.g. with
>
>(in Pth
>   (until (eof)
>  (let? Lst (mapcar pack (split (line) " "))
> ... operate on list of strings ...
>
>
> > Some of the files split their strings (that match the list elements) over
> > multiple lines making things a bit more involved than (if (member Ln
> List)
>
> I see. Then it is perhaps better not to use 'line', but 'from' / 'till', or
> perhaps even a lower level with 'char'.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


dealing with bad input ']' when reading and printing lines in a text file

2017-01-24 Thread dean
(de main (Pth)
   (in Pth (until (eof)
  (setq Rec (str (line T)))
  (prinl Rec)


The above is giving me Bad input ']'
I wrongly thought str would cope with this
Any hep much appreciated


re (NIL) vs nothing

2017-01-27 Thread dean
re my last post/thread
I don't want to waste anyone's time so please hold fire...
I've split the filtering and chopping in two and even the filtered member
LIst is disappearing
(as a result of just filtering (when it shouldn't)
so the problem doesn't look like it's to do with chopping the values down
to NIL.
I'll keep working on it.
Best Regards
Dean


(NIL) vs Nothing

2017-01-27 Thread dean
I've got this filtering function

(de fltr (Buf Ln)
   (setq New_buf (mapcar '((Ele) (pack (tail (- (length Ln)) (chop Ele
  (filter '((Ele) (pre? Ln Ele)) Buf

If any element 'Ele' of Buf starts with Ln it get's put into New_buf
but not before the the Ln part is chopped off the front.
In an ideal world any matching Ele will be the SAME length as Ln but I've
found that Some matches are split over Consecutive lines.
The first example below shows that Ln=Ele i.e. returning (NIL)Any NIL
in New_buf will end the search satisfactorily...I only need one!

#: (fltr '(aa ab) 'ab)
#-> (NIL)

These show what happens when the match is split over multiple lines i.e. it
gets there in the end.

#: (setq L (fltr '(aa ab) 'a))
#-> ("a" "b")
#: (fltr L 'b)
#-> (NIL)

My problem is that the "real" code is more involved and in order not to
have to write it out in "fully" for each time I use it (3) I thought I'd
use objects.
Whilst the 'ab match properly returns (NIL)the split match i.e. 'a and
then 'b cause the member New_buf to disappear altogether from the object
i.e. not return (NIL) like above.
I thought I'd test if (NIL) means nothing but get that NIL in (NIL) is
undefined.

(if (= NIL (NIL)) (prinl "yes") (prinl "no"))
#!? (NIL)
#NIL -- Undefined

Is there a good reason why New_buf should disappear rather hold (NIL) when
this is done in an object
and is NIL in (NIL) undefined when it gets returned as shown above?
Any advice much appreciated
I could move around this problem by doing the filtering and chopping in two
stages with some testing in between
but thought it would help with my development to ask.


Re: (NIL) vs Nothing

2017-01-30 Thread dean
I'm applying a method mthd> *Obj to each line of a file in turn. I've
tracked a problem down to when that method operates on line 3738 but am
unsure of exactly how to trace the method from that point on. I see that
trace operates in debug mode but again am not exactly sure how to ensure
that I am in debug mode on a method (rather than a function which is just
(debug 'Fn) at that point.
I have tried but get can't trace.
Any help much appreciated.

On 29 January 2017 at 15:29, dean <deangwillia...@gmail.com> wrote:

> I've just tried sprinkling (!) in my source.
> That is going to help me A LOT. It looks like the PL equivalent of int 3 :)
> .
> .
>
> On 29 January 2017 at 15:19, dean <deangwillia...@gmail.com> wrote:
>
>> Hi Alex
>> Thank you for the adviceI've just this minute used debug by
>> coincidence...but not with breakpoint and I've never used trace.
>> so thank you for those and also for putting me straight re the
>> positioning and syntax of (let (A 1 B 2..
>> Please have a good rest of the weekend.
>> Best Regards
>> Dean
>>
>> On 29 January 2017 at 14:42, Alexander Burger <a...@software-lab.de>
>> wrote:
>>
>>> Hi Dean,
>>>
>>> > I'm tending to develop functions in isolation so I can watch them like
>>> a
>>> > hawk.
>>>
>>> Watching like a hawk is always good! ;)
>>>
>>> In addition to that, I would recommend to use 'trace' and 'debug'.
>>> Especially
>>> 'trace' is more useful than it may seem, letting you monitor your whole
>>> program's behavior selectively. Individual functions can be
>>> single-stepped with
>>> 'debug', or by manually setting a breakpoint '!' with 'edit' or in the
>>> source
>>> code.
>>>
>>>
>>> > (let Some_sym...
>>> >   Some_sym is seen anywhere up to the closing bracket above  ---)
>>> >
>>> > but then I seem to want to access Some_sym beyond the closing bracket
>>> > SEEMINGLY dictated by the flow of control.
>>>
>>> Just move '(let Some_sym ...' up.
>>>
>>>
>>> > (let A 1 B2
>>> >
>>> > write your program as usual here safe in the knowledge that you have
>>> access
>>> > to A and B
>>>
>>> I think you mean
>>>
>>>(let (A 1  B 2)
>>>   ... )
>>>
>>> ♪♫ Alex
>>> --
>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>
>>
>>
>


Re: (NIL) vs Nothing

2017-01-30 Thread dean
Hi Alex
Yes that worked great preceded by a testi.e. whizzing through all file
lines in the input file until almost the 4000th which triggered reporting
on the method of interests's input and output. Thank you very much for the
advice.
Best Regards
Dean

On 30 January 2017 at 11:07, Alexander Burger <a...@software-lab.de> wrote:

> Hi Dean,
>
> > trace operates in debug mode but again am not exactly sure how to ensure
> > that I am in debug mode on a method (rather than a function which is just
> > (debug 'Fn) at that point.
> > I have tried but get can't trace.
>
> While (trace 'foo) traces a function, (trace 'meth> '+Class) traces a
> method.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: (NIL) vs Nothing

2017-01-28 Thread dean
That' greatthank you for both examples.

On 27 January 2017 at 19:03, Alexander Burger <a...@software-lab.de> wrote:

> Hi Dean,
>
> > (de fltr (Buf Ln)
> >(setq New_buf (mapcar '((Ele) (pack (tail (- (length Ln)) (chop
> Ele
> >   (filter '((Ele) (pre? Ln Ele)) Buf
> > ...
> > #: (fltr '(aa ab) 'ab)
> > #-> (NIL)
>
> You can use 'extract' to get exactly the results you need:
>
>(de fltr (Buf Ln)
>   (let N (inc (length Ln))
>  (extract
> '((Ele)
>(when (pre? Ln Ele)
>   (pack (nth (chop Ele) N)) ) )
> Buf ) ) )
>
>
> Perhaps 'match' is more elegant than 'pre?' and 'nth' or 'tail':
>
>(de fltr (Buf Ln)
>   (let Pat (conc (chop Ln) '(@Rest))
>  (use @Rest
> (extract
>'((Ele)
>   (and (match Pat (chop Ele)) (pack @Rest)) )
>Buf ) ) ) )
>
> In both cases:
>
>: (msg (fltr '(aa ab abc) 'ab))
>-> ("c")
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Matching and Hashes

2017-01-25 Thread dean
I've just found filter (which looks like find ALL) whilst reading up on
find sothank you very much both for the question and answer.









On 25 January 2017 at 07:03, Alexander Burger  wrote:

> Hi Joe,
>
> > (de account-list
> >   ("Bank Charge"."Expenses:Bank Fee") # matches if in
> last position
> >   ("City Market"."Expenses:Groceries")# ONLY this line works to
> match
> > )
> > (de determine-acct (desc)
> >   (for x account-list # go through account list
> >   (when (sub? (car x) desc)
> >   (cdr x  # on match
> return expense category
>
> The problem is that the loops does not exit upon a match.
>
> You could either do
>
>(de determine-acct (Desc)
>   (for X account-list
>  (T (sub? (car X) Desc)
> (cdr X) ) ) )
>
> or use 'find'
>
>(de determine-acct (Desc)
>   (find
>  '((X) (sub? (car X) Desc))
>  account-list ) )
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: executing a function + argument passed in as an argument to

2017-01-20 Thread dean
Thank you Alex...that's great.
I just came back to say that the above worked well for both strings and
numbers entered directly as the passed functions argument but not (it seems
:) ) for when the argument is supplied in a symbol. eval might well cope
with that and if not...I'll work on it.

Note, btw, that (car (cdr X)) can be simplified to (cadr X)

I thought that initially too but as you can see here (cdr Canned_fn) gives
a problem
whereas (car (cdr Canned_fn)) removes the parens that get put around Num.
I don't need the car for a string argument in another example so...
there could well be something wrong with this example

(de x2 (Num) (setq Res (* Num 2)))
(de fnfn (Canned_fn) (wait 1000)
   ((car Canned_fn) (cdr Canned_fn))) #calling a canned fn passed as arg
(prinl (x2 3)) #testing straight fn call -> 6
(prinl (fnfn '(x2 4))) #calling x2 as canned fn->8

Best Regards
Dean

On 20 January 2017 at 18:55, Alexander Burger <a...@software-lab.de> wrote:

> On Fri, Jan 20, 2017 at 06:26:14PM +, dean wrote:
> > I seem to be able to do this by
> > (de some_fn (Canned_fn_and_arg..
> >
> > and then executing the Canned_fn_and_arg inside some_fn by doing
> > ((car Canned_fn) (car (cdr Canned_fn)))
> >
> > Is this the right way or is there a slicker one?
>
> It depends on how 'Canned_fn_and_arg' looks like.
>
>
> I suspect that instead of
>
>((car Canned_fn) (car (cdr Canned_fn)))
>
> you could just call
>
>(eval Canned_fn)
>
> ♪♫ Alex
>
>
> Note, btw, that (car (cdr X)) can be simplified to (cadr X)
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: executing a function + argument passed in as an argument to

2017-01-20 Thread dean
This is how I did it where the argument to the canned/passed in function is
supplied as a symbol...
(de x2 (Num) (setq Res (* Num 2)))
(de fnfn (Canned_fn)
   #(setq X (car (cdr Canned_fn))) ((car Canned_fn) (eval X)))
   #replaced by single stage...
   ((car Canned_fn) (eval (car (cdr Canned_fn)
(setq Some_num 4)
(prinl (fnfn '(x2 Some_num))) #->8

Hope this is ok

On 20 January 2017 at 19:20, dean <deangwillia...@gmail.com> wrote:

> Thank you Alex...that's great.
> I just came back to say that the above worked well for both strings and
> numbers entered directly as the passed functions argument but not (it seems
> :) ) for when the argument is supplied in a symbol. eval might well cope
> with that and if not...I'll work on it.
>
> Note, btw, that (car (cdr X)) can be simplified to (cadr X)
>
> I thought that initially too but as you can see here (cdr Canned_fn) gives
> a problem
> whereas (car (cdr Canned_fn)) removes the parens that get put around Num.
> I don't need the car for a string argument in another example so...
> there could well be something wrong with this example
>
> (de x2 (Num) (setq Res (* Num 2)))
> (de fnfn (Canned_fn) (wait 1000)
>((car Canned_fn) (cdr Canned_fn))) #calling a canned fn passed as arg
> (prinl (x2 3)) #testing straight fn call -> 6
> (prinl (fnfn '(x2 4))) #calling x2 as canned fn->8
>
> Best Regards
> Dean
>
> On 20 January 2017 at 18:55, Alexander Burger <a...@software-lab.de> wrote:
>
>> On Fri, Jan 20, 2017 at 06:26:14PM +, dean wrote:
>> > I seem to be able to do this by
>> > (de some_fn (Canned_fn_and_arg..
>> >
>> > and then executing the Canned_fn_and_arg inside some_fn by doing
>> > ((car Canned_fn) (car (cdr Canned_fn)))
>> >
>> > Is this the right way or is there a slicker one?
>>
>> It depends on how 'Canned_fn_and_arg' looks like.
>>
>>
>> I suspect that instead of
>>
>>((car Canned_fn) (car (cdr Canned_fn)))
>>
>> you could just call
>>
>>(eval Canned_fn)
>>
>> ♪♫ Alex
>>
>>
>> Note, btw, that (car (cdr X)) can be simplified to (cadr X)
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Is there a shorter syntax for calling a method from a method in the

2017-01-26 Thread dean
i.e. I'm calling m1 from m2 using the same syntax as calling methods
externallybut just replacing *Obj with This.
No problem if not butIs there a shorter way e.g. like (: member)
instead of (get This 'member)
(class +Clss)
   (dm T ())
   (dm m1> () (setq Res 4))
   (dm m2> (Arg2) (+ (send 'm1> This) Arg2))

(setq *Obj (new '(+Clss)))
(prinl (format (send 'm2> *Obj 5)))


Re: Is there a shorter syntax for calling a method from a method in

2017-01-27 Thread dean
Hi Alex
That's great...thank you very much.
Best Regards
Dean

On 27 January 2017 at 06:53, Alexander Burger <a...@software-lab.de> wrote:

> Hi Dean,
>
> > i.e. I'm calling m1 from m2 using the same syntax as calling methods
> > externallybut just replacing *Obj with This.
>
> Yes, that's fine.
>
> > No problem if not butIs there a shorter way e.g. like (: member)
> > instead of (get This 'member)
>
> Yes, (: member) is the same as (get This 'member) or (; This member).
> 'member'
> doesn't show up in your code though.
>
> > (class +Clss)
> >(dm T ())
> >(dm m1> () (setq Res 4))
> >(dm m2> (Arg2) (+ (send 'm1> This) Arg2))
>
> Instead of (send 'm1> This) you would usually write (m1> This)
>
>
> > (setq *Obj (new '(+Clss)))
> > (prinl (format (send 'm2> *Obj 5)))
>
> and (m2> Obj 5)
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: (NIL) vs Nothing

2017-01-29 Thread dean
Hi Chrostophe and Alex

Thank you very much for your adviceIt is very timely.

I'm only too aware of the dangers of using setq, having been bitten a few
times now by interference between functions in my whole program.

I'm tending to develop functions in isolation so I can watch them like a
hawk. setq isn't a problem in such isolation and the ONLY reason I'm  using
setq is my lack of adeptness reconciling the the scoping inherent in "let"
with the bracketing I THINK I need to obtain the desired flow of control
i.e.

(let Some_sym...
  Some_sym is seen anywhere up to the closing bracket above  ---)

but then I seem to want to access Some_sym beyond the closing bracket
SEEMINGLY dictated by the flow of control.

Having just sorted out my first object's logic and layout now is probably a
good time to go back and replace all of my setq's with let's. If either of
you have any advice on how best to use "let"...I'd certainly welcome it
i.e. is it just a case of

(let A 1 B2


write your program as usual here safe in the knowledge that you have access
to A and B


)

I tried this but don't seem to get B

: (let A 1 B 2
(prinl A)
(prinl B)
)
1


I would like to crack this so any advice re how to correctly use "let"
would be very welcome and appreciated. BTWPL's object system is a
pleasure to use. Thank you for it!

Best Regards
Dean








On 28 January 2017 at 19:13, Alexander Burger <a...@software-lab.de> wrote:

> Hi Christophe,
>
> > > (de fltr (Buf Ln)
> > >(setq New_buf (mapcar '((Ele) (pack (tail (- (length Ln)) (chop
> Ele
> > >   (filter '((Ele) (pre? Ln Ele)) Buf
> >
> > I'm not an expert, I just want to warn and maybe be confirmed.
> > As Alex said recently, PicoLisp programs should rarely use setq.
>
> Indeed! When I saw the above definition, I was ready to say something
> about it.
> But then I understood that Dean obviously just extracted a sample from some
> other code he is working on, and that the 'setq' might be the remains of
> experimentation.
>
>
> > I'd add (please confirm):
> > 1) especially in function definitions, as
> > 2) it creates/modifies like «global variables», which many consider
> > bad practice.
>
> Yes. At least - if it is really necessary - is should be named '*New_buf'
> to
> mark it clearly as a global.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: (NIL) vs Nothing

2017-01-29 Thread dean
Hi Alex
Thank you for the adviceI've just this minute used debug by
coincidence...but not with breakpoint and I've never used trace.
so thank you for those and also for putting me straight re the positioning
and syntax of (let (A 1 B 2..
Please have a good rest of the weekend.
Best Regards
Dean

On 29 January 2017 at 14:42, Alexander Burger <a...@software-lab.de> wrote:

> Hi Dean,
>
> > I'm tending to develop functions in isolation so I can watch them like a
> > hawk.
>
> Watching like a hawk is always good! ;)
>
> In addition to that, I would recommend to use 'trace' and 'debug'.
> Especially
> 'trace' is more useful than it may seem, letting you monitor your whole
> program's behavior selectively. Individual functions can be single-stepped
> with
> 'debug', or by manually setting a breakpoint '!' with 'edit' or in the
> source
> code.
>
>
> > (let Some_sym...
> >   Some_sym is seen anywhere up to the closing bracket above  ---)
> >
> > but then I seem to want to access Some_sym beyond the closing bracket
> > SEEMINGLY dictated by the flow of control.
>
> Just move '(let Some_sym ...' up.
>
>
> > (let A 1 B2
> >
> > write your program as usual here safe in the knowledge that you have
> access
> > to A and B
>
> I think you mean
>
>(let (A 1  B 2)
>   ... )
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: (NIL) vs Nothing

2017-01-29 Thread dean
I've just tried sprinkling (!) in my source.
That is going to help me A LOT. It looks like the PL equivalent of int 3 :)


Re: (NIL) vs Nothing

2017-01-29 Thread dean
If we take objects as an example...You might want to use these to create
static variables using object properties which you want to persist within a
limited scope. You might setq the object itself to make it persist but do
you manipulate the objects properties (that you want to persist) using setq
or let inside the object's methods. I'm sure the answer will become clear
after experimenting with let but I'm not sure at the moment.

On 29 January 2017 at 11:47, dean <deangwillia...@gmail.com> wrote:

> Hi Chrostophe and Alex
>
> Thank you very much for your adviceIt is very timely.
>
> I'm only too aware of the dangers of using setq, having been bitten a few
> times now by interference between functions in my whole program.
>
> I'm tending to develop functions in isolation so I can watch them like a
> hawk. setq isn't a problem in such isolation and the ONLY reason I'm  using
> setq is my lack of adeptness reconciling the the scoping inherent in "let"
> with the bracketing I THINK I need to obtain the desired flow of control
> i.e.
>
> (let Some_sym...
>   Some_sym is seen anywhere up to the closing bracket above  ---)
>
> but then I seem to want to access Some_sym beyond the closing bracket
> SEEMINGLY dictated by the flow of control.
>
> Having just sorted out my first object's logic and layout now is probably
> a good time to go back and replace all of my setq's with let's. If either
> of you have any advice on how best to use "let"...I'd certainly welcome it
> i.e. is it just a case of
>
> (let A 1 B2
>
>
> write your program as usual here safe in the knowledge that you have
> access to A and B
>
>
> )
>
> I tried this but don't seem to get B
>
> : (let A 1 B 2
> (prinl A)
> (prinl B)
> )
> 1
>
>
> I would like to crack this so any advice re how to correctly use "let"
> would be very welcome and appreciated. BTWPL's object system is a
> pleasure to use. Thank you for it!
>
> Best Regards
> Dean
>
>
>
>
>
>
>
>
> On 28 January 2017 at 19:13, Alexander Burger <a...@software-lab.de> wrote:
>
>> Hi Christophe,
>>
>> > > (de fltr (Buf Ln)
>> > >(setq New_buf (mapcar '((Ele) (pack (tail (- (length Ln)) (chop
>> Ele
>> > >   (filter '((Ele) (pre? Ln Ele)) Buf))))
>> >
>> > I'm not an expert, I just want to warn and maybe be confirmed.
>> > As Alex said recently, PicoLisp programs should rarely use setq.
>>
>> Indeed! When I saw the above definition, I was ready to say something
>> about it.
>> But then I understood that Dean obviously just extracted a sample from
>> some
>> other code he is working on, and that the 'setq' might be the remains of
>> experimentation.
>>
>>
>> > I'd add (please confirm):
>> > 1) especially in function definitions, as
>> > 2) it creates/modifies like «global variables», which many consider
>> > bad practice.
>>
>> Yes. At least - if it is really necessary - is should be named '*New_buf'
>> to
>> mark it clearly as a global.
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


help with global replace in text file/list of bytes

2017-02-21 Thread dean
I need to globally replace certain words in a text file and because
I need to process it a byte at a time initially...I'm inputting
processed list of bytes into the global replace function "lchg"
(and others) like this.

(lbytes_to_fl Cleaned_txt_pth
   (lchg "fl ow" "flow"
   (fltr2
   (fltr1
(fl_to_lbytes Txt_pth)

The other filters seem ok but this one is slow (most likely my
algorithm/general approach :)) and any help to
speed things up would be much appreciated.

(de lchg (Sfrom Sto Lbytes)
   (make
  (let
 (X 0
B NIL
Lfrom (mapcar char (chop Sfrom))
Lto (mapcar char (chop Sto))
First_from_ch (car Lfrom)
Len_from-1 (- (length Lfrom) 1)
Len_lbytes (length Lbytes) )
 (until (<= (length Lbytes) X)
(inc 'X)
(setq B (get Lbytes X))
(if (= B First_from_ch)
   (prog
  (if (= (slice Lbytes X (+ X Len_from-1)) Lfrom)
 (prog
(for MatchB Lto
   (link MatchB) )
(inc 'X Len_from-1) )
 (link B) ) )
   (link B) ) ) ) ) )

   (de slice (Lst I K) (head (inc (- K I)) (nth Lst I)) ) #99

Here's "lchg" in action...

: (setq L (chop "ab fl ow flow fl ow yz"))
-> ("a" "b" " " "f" "l" " " "o" "w" " " "f" "l" "o" "w" " " "f" "l" " " "o"
"w" " " "y" "z")
: (pack (mapcar char (lchg "fl ow" "flow" (mapcar char L
-> "ab flow flow flow yz"


Re: help with global replace in text file/list of bytes

2017-02-21 Thread dean
Hi Andreas
>Do you really need to load all the stuff into RAM?
No...I was originally using in/out
and will go back to trying that for each filter.

re the improvements...yes I understand all all of those...thank you.
>exactly the same structure as in ram.
Amazing and I'll bear that in mind.

>I hope this helps...
Yes it does and thank you very much

Hi Joe
>1. Your picolisp code is becoming easier to read.
That's very kind...thank you...I am trying :)

>3. Why do you need to work with bytes vs chars?
Good question...Initially I have some >130 asci characters.
Reading them as such is problematic but viewing them as bytes
and changing those >asci 130 solves the problem.
As the data is in bytes after such conversion I thought it might be
more efficient to keep them that way but after
your question,
Rosetta Code example
and Andreas' advice re confining things to in/out
...maybe not.
I'll have a go trying to incorporate the above advice and example
and report back. It might take me a while.

Thank you both very much for your help.
Best Regards
Dean

On 21 February 2017 at 13:14, Joe Bogner <joebog...@gmail.com> wrote:

> After trying to figure it out myself for a few minutes, I remembered to
> check rosettacode (wonderful resource). This is probably close to what you
> need: http://rosettacode.org/wiki/Globally_replace_text_in_
> several_files#PicoLisp
>
> On Tue, Feb 21, 2017 at 8:08 AM, Joe Bogner <joebog...@gmail.com> wrote:
>
>> Hi dean,
>>
>> I experimented with this problem for a few minutes and didn't come up
>> with anything worth posting. A few comments though:
>>
>> 1. Your picolisp code is becoming easier to read. Nice work!
>> 2. My initial thought was to split the input into words and replace
>> sublists, however it looks like you don't have a word delimiter (typically
>> a space)...Since you need to be able to substitute "fl ow" with "flow". As
>> a result, the best I came up with is something similar (looping through
>> characters and testing the replacement)
>> 3. Why do you need to work with bytes vs chars?  (mapcar char (chop
>> Sfrom)) ?
>>
>>
>>
>> On Tue, Feb 21, 2017 at 3:37 AM, dean <deangwillia...@gmail.com> wrote:
>>
>>> I need to globally replace certain words in a text file and because
>>> I need to process it a byte at a time initially...I'm inputting
>>> processed list of bytes into the global replace function "lchg"
>>> (and others) like this.
>>>
>>> (lbytes_to_fl Cleaned_txt_pth
>>>(lchg "fl ow" "flow"
>>>(fltr2
>>>(fltr1
>>> (fl_to_lbytes Txt_pth)
>>>
>>> The other filters seem ok but this one is slow (most likely my
>>> algorithm/general approach :)) and any help to
>>> speed things up would be much appreciated.
>>>
>>> (de lchg (Sfrom Sto Lbytes)
>>>(make
>>>   (let
>>>  (X 0
>>> B NIL
>>> Lfrom (mapcar char (chop Sfrom))
>>> Lto (mapcar char (chop Sto))
>>> First_from_ch (car Lfrom)
>>> Len_from-1 (- (length Lfrom) 1)
>>> Len_lbytes (length Lbytes) )
>>>  (until (<= (length Lbytes) X)
>>> (inc 'X)
>>> (setq B (get Lbytes X))
>>> (if (= B First_from_ch)
>>>(prog
>>>   (if (= (slice Lbytes X (+ X Len_from-1)) Lfrom)
>>>  (prog
>>> (for MatchB Lto
>>>(link MatchB) )
>>> (inc 'X Len_from-1) )
>>>  (link B) ) )
>>>(link B) ) ) ) ) )
>>>
>>>(de slice (Lst I K) (head (inc (- K I)) (nth Lst I)) ) #99
>>>
>>> Here's "lchg" in action...
>>>
>>> : (setq L (chop "ab fl ow flow fl ow yz"))
>>> -> ("a" "b" " " "f" "l" " " "o" "w" " " "f" "l" "o" "w" " " "f" "l" " "
>>> "o" "w" " " "y" "z")
>>> : (pack (mapcar char (lchg "fl ow" "flow" (mapcar char L
>>> -> "ab flow flow flow yz"
>>>
>>>
>>
>


Re: help with global replace in text file/list of bytes

2017-02-21 Thread dean
PS ..yes that Rosetta Code example is close to what I'm after.

On 21 February 2017 at 15:19, dean <deangwillia...@gmail.com> wrote:

> Hi Andreas
> >Do you really need to load all the stuff into RAM?
> No...I was originally using in/out
> and will go back to trying that for each filter.
>
> re the improvements...yes I understand all all of those...thank you.
> >exactly the same structure as in ram.
> Amazing and I'll bear that in mind.
>
> >I hope this helps...
> Yes it does and thank you very much
>
> Hi Joe
> >1. Your picolisp code is becoming easier to read.
> That's very kind...thank you...I am trying :)
>
> >3. Why do you need to work with bytes vs chars?
> Good question...Initially I have some >130 asci characters.
> Reading them as such is problematic but viewing them as bytes
> and changing those >asci 130 solves the problem.
> As the data is in bytes after such conversion I thought it might be
> more efficient to keep them that way but after
> your question,
> Rosetta Code example
> and Andreas' advice re confining things to in/out
> maybe not.
> I'll have a go trying to incorporate the above advice and example
> and report back. It might take me a while.
>
> Thank you both very much for your help.
> Best Regards
> Dean
>
> On 21 February 2017 at 13:14, Joe Bogner <joebog...@gmail.com> wrote:
>
>> After trying to figure it out myself for a few minutes, I remembered to
>> check rosettacode (wonderful resource). This is probably close to what you
>> need: http://rosettacode.org/wiki/Globally_replace_text_in_s
>> everal_files#PicoLisp
>>
>> On Tue, Feb 21, 2017 at 8:08 AM, Joe Bogner <joebog...@gmail.com> wrote:
>>
>>> Hi dean,
>>>
>>> I experimented with this problem for a few minutes and didn't come up
>>> with anything worth posting. A few comments though:
>>>
>>> 1. Your picolisp code is becoming easier to read. Nice work!
>>> 2. My initial thought was to split the input into words and replace
>>> sublists, however it looks like you don't have a word delimiter (typically
>>> a space)...Since you need to be able to substitute "fl ow" with "flow". As
>>> a result, the best I came up with is something similar (looping through
>>> characters and testing the replacement)
>>> 3. Why do you need to work with bytes vs chars?  (mapcar char (chop
>>> Sfrom)) ?
>>>
>>>
>>>
>>> On Tue, Feb 21, 2017 at 3:37 AM, dean <deangwillia...@gmail.com> wrote:
>>>
>>>> I need to globally replace certain words in a text file and because
>>>> I need to process it a byte at a time initially...I'm inputting
>>>> processed list of bytes into the global replace function "lchg"
>>>> (and others) like this.
>>>>
>>>> (lbytes_to_fl Cleaned_txt_pth
>>>>(lchg "fl ow" "flow"
>>>>(fltr2
>>>>(fltr1
>>>> (fl_to_lbytes Txt_pth)
>>>>
>>>> The other filters seem ok but this one is slow (most likely my
>>>> algorithm/general approach :)) and any help to
>>>> speed things up would be much appreciated.
>>>>
>>>> (de lchg (Sfrom Sto Lbytes)
>>>>(make
>>>>   (let
>>>>  (X 0
>>>> B NIL
>>>> Lfrom (mapcar char (chop Sfrom))
>>>> Lto (mapcar char (chop Sto))
>>>> First_from_ch (car Lfrom)
>>>> Len_from-1 (- (length Lfrom) 1)
>>>> Len_lbytes (length Lbytes) )
>>>>  (until (<= (length Lbytes) X)
>>>> (inc 'X)
>>>> (setq B (get Lbytes X))
>>>> (if (= B First_from_ch)
>>>>(prog
>>>>   (if (= (slice Lbytes X (+ X Len_from-1)) Lfrom)
>>>>  (prog
>>>> (for MatchB Lto
>>>>(link MatchB) )
>>>> (inc 'X Len_from-1) )
>>>>  (link B) ) )
>>>>(link B) ) ) ) ) )
>>>>
>>>>(de slice (Lst I K) (head (inc (- K I)) (nth Lst I)) ) #99
>>>>
>>>> Here's "lchg" in action...
>>>>
>>>> : (setq L (chop "ab fl ow flow fl ow yz"))
>>>> -> ("a" "b" " " "f" "l" " " "o" "w" " " "f" "l" "o" "w" " " "f" "l" " "
>>>> "o" "w" " " "y" "z")
>>>> : (pack (mapcar char (lchg "fl ow" "flow" (mapcar char L
>>>> -> "ab flow flow flow yz"
>>>>
>>>>
>>>
>>
>


clip and chop down consecutive "internal" white spaces to one space??

2017-02-17 Thread dean
I've done this and it works but...is there a slicker way :)

(setq S " this contains 2  consecutive spaces ")

(de shrink (Str)
   #can't clip before inner pack so need to pack, chop, clip and re-pack
   (pack
  (clip
 (chop
(pack
   (let (Last_ch " ")
   (make
  (for Ch (chop Str)
 (if (<> Ch " ")
(if (= Last_ch " ")
   (link (pack " " Ch))
   (link Ch)))
 (setq Last_ch Ch)


(prinl "'" (shrink S) "'")

#'this contains 2 consecutive spaces'


Re: clip and chop down consecutive "internal" white spaces to one space??

2017-02-18 Thread dean
Joe, LindsayYes! they both do it and are MUCH slicker :) than the
improvement I managed overnight i.e. moving the clip down into the for loop
:)
That's great. Thank you very much.

(de shrink (Str)
   (pack
  (let (Last_ch "A")
  (make
 (for Ch (clip (chop Str))
(if (<> Ch " ")
   (if (= Last_ch " ")
  (link (pack " " Ch))
  (link Ch)))
    (setq Last_ch Ch))

Best Regards
Dean

On 18 February 2017 at 06:39, Lindsay John Lawrence <
lawrence.lindsayj...@gmail.com> wrote:

>
> (de trimmr (S C)
>(default C " ")
>(glue C (filter '((E) E) (split (chop S) C
>
> : (setq Str "   spaaaces, spaaaces   everywhere  spaaaces spaaaces r so
> squuare   ")
> -> "   spaaaces, spaaaces   everywhere  spaaaces spaaaces r so squuare   "
> : (trimmr (trimmr Str) "a")
>
> -> "spaces, spaces everywhere spaces spaces r so squuare"
>
> /Lindsay
>


Re: clip and chop down consecutive "internal" white spaces to one

2017-02-18 Thread dean
Hi Alex
Thank you very much for the elaboration. It helps a lot.
Best Regards
Dean

On 18 February 2017 at 08:11, Alexander Burger <a...@software-lab.de> wrote:

> Hi Lindsay,
>
> >(glue C (filter '((E) E) (split (chop S) C
>
> I would do the same.
>
> Just one minor improvement:
>
> Because calling an EXPR function like ((E) E) is relatively expensive, I
> generally recommend to use 'prog' for the identity function:
>
>(glue C (filter prog (split (chop S) C
>
>: ('((E) E) 123)
>-> 123
>
>: (prog 123)
>-> 123
>
>
> In the above case, where we just filter the list and and thus just need a
> boolean result, I'd use 'bool':
>
>(glue C (filter bool (split (chop S) C
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: help with global replace in text file/list of bytes

2017-02-21 Thread dean
I've converted all of my filters to use in/out and have made the above
virtually identical to that Rosetta Code example and the result is
now.virtually instantaneousjust for the cost of a couple of
temporary files. The difference is remarkable and again thank you both for
steering me in this direction.

(de lchg (From To Ipth Opth)
   (out Opth
  (in Ipth
 (while (echo From)
(prin To)

On 21 February 2017 at 15:20, dean <deangwillia...@gmail.com> wrote:

> PS ..yes that Rosetta Code example is close to what I'm after.
>
> On 21 February 2017 at 15:19, dean <deangwillia...@gmail.com> wrote:
>
>> Hi Andreas
>> >Do you really need to load all the stuff into RAM?
>> No...I was originally using in/out
>> and will go back to trying that for each filter.
>>
>> re the improvements...yes I understand all all of those...thank you.
>> >exactly the same structure as in ram.
>> Amazing and I'll bear that in mind.
>>
>> >I hope this helps...
>> Yes it does and thank you very much
>>
>> Hi Joe
>> >1. Your picolisp code is becoming easier to read.
>> That's very kind...thank you...I am trying :)
>>
>> >3. Why do you need to work with bytes vs chars?
>> Good question...Initially I have some >130 asci characters.
>> Reading them as such is problematic but viewing them as bytes
>> and changing those >asci 130 solves the problem.
>> As the data is in bytes after such conversion I thought it might be
>> more efficient to keep them that way but after
>> your question,
>> Rosetta Code example
>> and Andreas' advice re confining things to in/out
>> maybe not.
>> I'll have a go trying to incorporate the above advice and example
>> and report back. It might take me a while.
>>
>> Thank you both very much for your help.
>> Best Regards
>> Dean
>>
>> On 21 February 2017 at 13:14, Joe Bogner <joebog...@gmail.com> wrote:
>>
>>> After trying to figure it out myself for a few minutes, I remembered to
>>> check rosettacode (wonderful resource). This is probably close to what you
>>> need: http://rosettacode.org/wiki/Globally_replace_text_in_s
>>> everal_files#PicoLisp
>>>
>>> On Tue, Feb 21, 2017 at 8:08 AM, Joe Bogner <joebog...@gmail.com> wrote:
>>>
>>>> Hi dean,
>>>>
>>>> I experimented with this problem for a few minutes and didn't come up
>>>> with anything worth posting. A few comments though:
>>>>
>>>> 1. Your picolisp code is becoming easier to read. Nice work!
>>>> 2. My initial thought was to split the input into words and replace
>>>> sublists, however it looks like you don't have a word delimiter (typically
>>>> a space)...Since you need to be able to substitute "fl ow" with "flow". As
>>>> a result, the best I came up with is something similar (looping through
>>>> characters and testing the replacement)
>>>> 3. Why do you need to work with bytes vs chars?  (mapcar char (chop
>>>> Sfrom)) ?
>>>>
>>>>
>>>>
>>>> On Tue, Feb 21, 2017 at 3:37 AM, dean <deangwillia...@gmail.com> wrote:
>>>>
>>>>> I need to globally replace certain words in a text file and because
>>>>> I need to process it a byte at a time initially...I'm inputting
>>>>> processed list of bytes into the global replace function "lchg"
>>>>> (and others) like this.
>>>>>
>>>>> (lbytes_to_fl Cleaned_txt_pth
>>>>>(lchg "fl ow" "flow"
>>>>>(fltr2
>>>>>(fltr1
>>>>> (fl_to_lbytes Txt_pth)
>>>>>
>>>>> The other filters seem ok but this one is slow (most likely my
>>>>> algorithm/general approach :)) and any help to
>>>>> speed things up would be much appreciated.
>>>>>
>>>>> (de lchg (Sfrom Sto Lbytes)
>>>>>(make
>>>>>   (let
>>>>>  (X 0
>>>>> B NIL
>>>>> Lfrom (mapcar char (chop Sfrom))
>>>>> Lto (mapcar char (chop Sto))
>>>>> First_from_ch (car Lfrom)
>>>>> Len_from-1 (- (length Lfrom) 1)
>>>>> Len_lbytes (length Lbytes) )
>>>>>  (until (<= (length Lbytes) X)
>>>>> (inc 'X)
>>>>> (setq B (get Lbytes X))
>>>>> (if (= B First_from_ch)
>>>>>(prog
>>>>>   (if (= (slice Lbytes X (+ X Len_from-1)) Lfrom)
>>>>>  (prog
>>>>> (for MatchB Lto
>>>>>(link MatchB) )
>>>>> (inc 'X Len_from-1) )
>>>>>  (link B) ) )
>>>>>(link B) ) ) ) ) )
>>>>>
>>>>>(de slice (Lst I K) (head (inc (- K I)) (nth Lst I)) ) #99
>>>>>
>>>>> Here's "lchg" in action...
>>>>>
>>>>> : (setq L (chop "ab fl ow flow fl ow yz"))
>>>>> -> ("a" "b" " " "f" "l" " " "o" "w" " " "f" "l" "o" "w" " " "f" "l" "
>>>>> " "o" "w" " " "y" "z")
>>>>> : (pack (mapcar char (lchg "fl ow" "flow" (mapcar char L
>>>>> -> "ab flow flow flow yz"
>>>>>
>>>>>
>>>>
>>>
>>
>


Re: trouble reading non blocking space etc

2017-02-14 Thread dean
Thank you very much for that Lindsay.
Apparently up to code128 Ascii encodings are the same as UTF-8.
After that things change and you can get clashes.
That A0 or 160 is a non-blocking backspace.
I'm just after alphanumeric characters but will need to convert those A0s
to ordinary spaces

This seems to do that but I'm ending up with a file where each character is
wrapped in double quotes and wonder how best to get rid of themPerhaps
linking them like you have, packing the whole list and then writing that as
a lump might be the best way but I'm just wondering if there's a slick way
of removing the double quotes from what (char Byte_code)) gives you. At the
moment the only way I know is (car (str (char Byte_code)))
but this right NIL in place of space.

(de add_byte (Byte_code)
   (out '+/home/me/test_fl.asc (print (char Byte_code

(out '/home/me/test_fl.asc) #clear file
(in "/home/me/test_fl.txt"
   (while (setq Byte_code (rd 1))
  (if (< Byte_code 129)
 (add_byte Byte_code)
 (case Byte_code
(160 (add_byte 32))

On 14 February 2017 at 17:34, Lindsay John Lawrence <
lawrence.lindsayj...@gmail.com> wrote:

> Not sure about file charset encoding (a0?)... But perhaps something like
> this...?
>
> $ xxd test.txt
> 000: 6869 a074 6865 6972 3aa0 686f 7720 6172  hi.their:.how ar
> 010: 6520 796f 750a   e you.
>
> : (pack
>   (make
>  (in "test.txt" (while (rd 1) (link (char @ ) )
> -> "hi their: how are you^J"
>
> # .. or without pack
> : (make (in "test.txt" (while (rd 1) (link (char @ )
> -> ("h" "i" " " "t" "h" "e" "i" "r" ":" " " "h" "o" "w" " " "a" "r" "e" "
> " "y" "o" "u" "^J")
>
> /Lindsay
>
>
> On Tue, Feb 14, 2017 at 8:33 AM, dean <deangwillia...@gmail.com> wrote:
>
>> Ok...It seems that (rd 1) doesn't work well with (until (eof) so I tried
>>
>> (in "/home/me/test_fl.txt"
>>(while (setq B (rd 1))
>>   (prinl (char B))
>>   (if (= (key) "x") (quit
>>
>> and "while" testing the output of "rd 1" worked fine
>>
>> On 14 February 2017 at 16:21, dean <deangwillia...@gmail.com> wrote:
>>
>>> Ok Done it now including the decimal codes and I'd previously seen both
>>> hex and hax so...this should keep me busy for a while :).
>>>
>>> (in "/home/me/test_fl.txt"
>>>(until (eof)
>>>   (setq B (rd 1))
>>>   (prinl B  )
>>>   (if (= (key) "x") (quit
>>>
>>> On 14 February 2017 at 15:50, dean <deangwillia...@gmail.com
>>> <deangwilliam30@gmailcom>> wrote:
>>>
>>>> This is the closest I've got i.e. the first byte seems to go into B now
>>>> but then I'm in an endless loop with B's value stuck with that first byte.
>>>>
>>>> (in "/home/me/test_fl.txt"
>>>>(until (eof)
>>>>   (setq B (pipe (echo 1) (read)))
>>>>   (prinl B)
>>>>   (if (= (key) "x") (quit
>>>>
>>>> On 14 February 2017 at 13:03, dean <deangwillia...@gmail.com> wrote:
>>>>
>>>>> My mistakeI haven't done it at all and what is moreI'm not
>>>>> sure how you get the hex value (or decimal value) of the byte to decide
>>>>> what to do with it.
>>>>>
>>>>> On 14 February 2017 at 12:38, dean <deangwillia...@gmail.com> wrote:
>>>>>
>>>>>> Done it :)
>>>>>>
>>>>>> (in "/home/me/test_fl.txt"
>>>>>>(until (eof)
>>>>>>   (echo 1)
>>>>>>   (setq B (in NIL))
>>>>>>   (prinl B)
>>>>>>   (key)))
>>>>>>
>>>>>>
>>>>>> On 14 February 2017 at 12:26, dean <deangwillia...@gmail.com> wrote:
>>>>>>
>>>>>>> Looking a possible ways around this I saw this in the tutorial :)
>>>>>>>
>>>>>>> (in "/home/me/test_fl.txt"
>>>>>>>(until (eof)
>>>>>>>   (echo 1)
>>>>>>>   (key)))
>>>>>>>
>>>>>>> and it works great. My problem is I don't know how to
>>>>

Re: trouble reading non blocking space etc

2017-02-13 Thread dean
Thank you very much for this!
I tried (cd src; make tools) both from the command line...because of "$"
and from within Picolisps RPL because of the parens.
I looked in src and there is just the utf2.c file.
When I do $ (cd src; make tools) from the command line I get...
$ (cd src; make tools)
*** Parse error in /home/me/picoLisp/src: Missing dependency operator
(Makefile:20)
*** Parse error: Need an operator in 'else' (Makefile:28)
*** Parse error: Missing dependency operator (Makefile:29)
*** Parse error: Need an operator in 'else' (Makefile:37)
etc.

which looks like
the block beginning
ifeg ($(shell uname), Linux)


Re: trouble reading non blocking space etc

2017-02-14 Thread dean
Looking a possible ways around this I saw this in the tutorial :)

(in "/home/me/test_fl.txt"
   (until (eof)
  (echo 1)
  (key)))

and it works great. My problem is I don't know how to
capture (echo 1)  into a symbol's val.


On 13 February 2017 at 23:03, dean <deangwillia...@gmail.com> wrote:

> Thank you very much for this!
> I tried (cd src; make tools) both from the command line...because of "$"
> and from within Picolisps RPL because of the parens.
> I looked in src and there is just the utf2.c file.
> When I do $ (cd src; make tools) from the command line I get...
> $ (cd src; make tools)
> *** Parse error in /home/me/picoLisp/src: Missing dependency operator
> (Makefile:20)
> *** Parse error: Need an operator in 'else' (Makefile:28)
> *** Parse error: Missing dependency operator (Makefile:29)
> *** Parse error: Need an operator in 'else' (Makefile:37)
> etc.
>
> which looks like
> the block beginning
> ifeg ($(shell uname), Linux)
> .
> .
> else
> ifeg ($(shell uname, OpenBSD)
> .
> .
> I'm the second i.e. OpenBSD option and know very nothing about makefiles.
> I'm on a 64 bit OS but am looking at two -m32 options in there.
> That might well be ok but I thought I'd mention it.
>
> Best Regards
> Dean
>
>
>
>
>
>
>
> On 13 February 2017 at 21:52, Alexander Burger <a...@software-lab.de>
> wrote:
>
>> Hi Dean,
>>
>> > 6869 a074 6865 6972 3aa0 686f 7720 6172 6520 796f 750a
>> > hi.their:.how are you.
>> >
>> > The following program...
>> >
>> > (in "/home/me/test_fl.txt"
>> >(until (eof)
>> >   (setq Ln (line T))
>> >   (prinl Ln)))
>> >
>> > results in this
>> >
>> > hiനeir:ਯw are you
>>
>> OK, as you noticed in your other mail, PicoLisp can handle *only* UTF-8
>> input.
>>
>>
>> > (load "@lib/import.l")
>>
>> This is probably not necessary here.
>>
>>
>> > (in '("bin/utf8" "/home/me/test_fl.txt")
>>
>> Good, that's the right way!
>>
>>
>> > bin/utf8: Can't exec
>>
>> Try this:
>>
>>$ (cd src; make tools)
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: trouble reading non blocking space etc

2017-02-14 Thread dean
Done it :)

(in "/home/me/test_fl.txt"
   (until (eof)
  (echo 1)
  (setq B (in NIL))
  (prinl B)
  (key)))


On 14 February 2017 at 12:26, dean <deangwillia...@gmail.com> wrote:

> Looking a possible ways around this I saw this in the tutorial :)
>
> (in "/home/me/test_fl.txt"
>(until (eof)
>   (echo 1)
>   (key)))
>
> and it works great. My problem is I don't know how to
> capture (echo 1)  into a symbol's val.
>
>
> On 13 February 2017 at 23:03, dean <deangwillia...@gmail.com> wrote:
>
>> Thank you very much for this!
>> I tried (cd src; make tools) both from the command line...because of "$"
>> and from within Picolisps RPL because of the parens.
>> I looked in src and there is just the utf2.c file.
>> When I do $ (cd src; make tools) from the command line I get...
>> $ (cd src; make tools)
>> *** Parse error in /home/me/picoLisp/src: Missing dependency operator
>> (Makefile:20)
>> *** Parse error: Need an operator in 'else' (Makefile:28)
>> *** Parse error: Missing dependency operator (Makefile:29)
>> *** Parse error: Need an operator in 'else' (Makefile:37)
>> etc.
>>
>> which looks like
>> the block beginning
>> ifeg ($(shell uname), Linux)
>> .
>> .
>> else
>> ifeg ($(shell uname, OpenBSD)
>> .
>> .
>> I'm the second i.e. OpenBSD option and know very nothing about makefiles

Re: trouble reading non blocking space etc

2017-02-14 Thread dean
My mistakeI haven't done it at all and what is moreI'm not sure how
you get the hex value (or decimal value) of the byte to decide what to do
with it.

On 14 February 2017 at 12:38, dean <deangwillia...@gmail.com> wrote:

> Done it :)
>
> (in "/home/me/test_fl.txt"
>(until (eof)
>   (echo 1)
>   (setq B (in NIL))
>   (prinl B)
>   (key)))
>
>
> On 14 February 2017 at 12:26, dean <deangwillia...@gmail.com> wrote:
>
>> Looking a possible ways around this I saw this in the tutorial :)
>>
>> (in "/home/me/test_fl.txt"
>>(until (eof)
>>   (echo 1)
>>   (key)))
>>
>> and it works great. My problem is I don't know how to
>> capture (echo 1)  into a symbol's val.
>>
>>
>> On 13 February 2017 at 23:03, dean <deangwillia...@gmail.com> wrote:
>>
>>> Thank you very much for this!
>>> I tried (cd src; make tools) both from the command line...because of "$"
>>> and from within Picolisps RPL because of the parens.
>>> I looked in src and there is just the utf2.c file.
>>> When I do $ (cd src; make tools) from the command line I get...
>>> $ (cd src; make tools)
>>> *** Parse error in /home/me/picoLisp/src: Missing dependency operator
>>> (Makefile:20)
>>> *** Parse error: Need an operator in 'else' (Makefile:28)
>>> *** Parse error: Missing dependency operator (Makefile:29)
>>> *** Parse error: Need an operator in 'else' (Makefile:37)
>>> etc.
>>>
>>> which looks like
>>> the block beginning
>>> ifeg ($(shell uname), Linux)
>>> .
>>> .
>>> else
>>> ifeg ($(shell uname, OpenBSD)
>>> .
>>> .
>>> I'm the second i.e. OpenBSD option and know very nothing about makefiles.
>>> I'm on a 64 bit OS but am looking at two -m32 options in there.
>>> That might well be ok but I thought I'd mention it.
>>>
>>> Best Regards
>>> Dean
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On 13 February 2017 at 21:52, Alexander Burger <a...@software-lab.de>
>>> wrote:
>>>
>>>> Hi Dean,
>>>>
>>>> > 6869 a074 6865 6972 3aa0 686f 7720 6172 6520 796f 750a
>>>> > hi.their:.how are you.
>>>> >
>>>> > The following program...
>>>> >
>>>> > (in "/home/me/test_fl.txt"
>>>> >(until (eof)
>>>> >   (setq Ln (line T))
>>>> >   (prinl Ln)))
>>>> >
>>>> > results in this
>>>> >
>>>> > hiനeir:ਯw are you
>>>>
>>>> OK, as you noticed in your other mail, PicoLisp can handle *only* UTF-8
>>>> input.
>>>>
>>>>
>>>> > (load "@lib/import.l")
>>>>
>>>> This is probably not necessary here.
>>>>
>>>>
>>>> > (in '("bin/utf8" "/home/me/test_fl.txt")
>>>>
>>>> Good, that's the right way!
>>>>
>>>>
>>>> > bin/utf8: Can't exec
>>>>
>>>> Try this:
>>>>
>>>>$ (cd src; make tools)
>>>>
>>>> ♪♫ Alex
>>>> --
>>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>>
>>>
>>>
>>
>


Re: unit testing?

2017-02-10 Thread dean
Hi andreas
That looks very good to me...thank you very much indeed!
Best Regards
Dean


On 10 February 2017 at 17:12, <andr...@itship.ch> wrote:

> Hi Dean
>
> PicoLisp is an interpreted language, so very dynamic.
> Therefore, why not just do it with a global flag variable?
>
> (off *Scaffolding) # do not load scaffolding
>
> 
>
> (de myCode ...)
>
> (when *Scaffolding
> (de myScaffoldingFunc1 ...)
> (de myScaffoldingFunc2 ...)
> (de myScaffoldingFunc3 ...) )
>
>
> So all the (de) is only executed if *Scaffolding is not NIL.
> (off *Scaffolding) sets global variable *Scaffolding to NIL.
> (on *Scaffolding) sets global variable to T (used as true in picolisp).
>
> This can be made even shorter:
>
> (off *Scaffolding) # or (on *Scaffolding), depending on context
>
> 
>
> (de myCode ...)
>
> `*Scaffolding # evaluate *Scaffolding during reading of the source file,
> when its NIL, (load)ing stops
>
> (de myScaffoldingFunc1 ...)
> (de myScaffoldingFunc2 ...)
> (de myScaffoldingFunc3 ...)
>
> Regards,
> beneroth
>
>
> - Original Message -
> From: dean [mailto:deangwillia...@gmail.com]
> To: picolisp@software-lab.de
> Sent: Wed, 8 Feb 2017 16:31:30 +
> Subject: Re: unit testing?
>
> Hi Alex and Christophe
> In Python that __name__ variable stops things like a local main proc from
> executing altogether...when Python detects that the module in which it
> exists no longer needs it because it is being loaded by a bigger program,
> which accesses the module's code like the local main does i.e. The local
> main is hidden from Python under such circumstances.
>
> I was wondering about the "once" situation toobecause I have
> experienced "function redeclared" or some such popping up. If you're
> telling me that such messages are inconsequential compared to the benefits
> of developing in a way which causes that.that's fine by me because it's
> easier to ignore the redeclaration messages than not :)
>
> Because PL seems to allow forward referencing...I was
> 1 Putting all the scaffolding down the bottom with my local main so it's
> all in the same place.
> 2 Commenting it all out...
> 3 Loading the module into the wider program and then
> 4 Comment the helper functions back in as PL reported their absence.
> Obviously the local main stays commented out.
> This seems fairly convenient but my interpretation of the above is I only
> need to comment out the local main and if that's right that's great.
>
> Thank you Chrostophe for the further explanation re Python.
>
> Best Regards
> Dean
>
>
>
>
>
>
> On 8 February 2017 at 14:47, Christophe Gragnic <
> christophegrag...@gmail.com
> > wrote:
>
> > On Wed, Feb 8, 2017 at 12:13 PM, Alexander Burger <a...@software-lab.de>
> > wrote:
> > >> I'm thinking of Python's `if __name__ == '__main__' and Perl's unless
> > >> (caller) {...}
> > >
> > > I don't know Python and Perl well enough. But perhaps 'once' is what
> you
> > think
> > > of?
> > >
> > > (once (load "xxx.l"))
> >
> > No, it's different.
> >
> > In Python there's a «magic» variable named __name__.
> > As files can be:
> > - imported from another script/module
> > - interpreted directly from top leve
> > it provides a trick to distinguish between those two ways to use a
> > script/module.
> > See here:
> > https://docs.python.org/3/library/__main__.html
> >
> >
> > chri
> > --
> > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
> >
>
>
>


altering LOCAL list elements

2017-02-10 Thread dean
Hi
I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
'Some_atom)
which gets me a long way...
..but what about list elements?


(setq L (0 0 0))
(de doit ()
   #(let L (0 0 0)
  (setq L (insert '1 (remove '1 L) 2))
  (prinl "L is " L)
   #)
)

When I "setq" L this works but can I do it (somehow) when L is created with
"let"?


Re: altering LOCAL list elements

2017-02-11 Thread dean
Hi Joh-tob & Joe
With setq L.(0 0 0) gets changed to (2 0 0) i.e. the replace is done by
index not matching value
With let L...(0 0 0) stays at (0 0 0)
I'd wanted the former in conjunction with let.
Thank you for the suggestion re need...and the explanation re let.
I can do this with setq but was just wondering if there was a way around
"setting" let'd values more than once...like you can with let'd
atoms...using inc and dec.
I don't think you can but didn't think you could with atoms until inc and
dec came back as an answer on this forum...hence this question :).
Thank you for your advice and best regards
Dean



On 11 February 2017 at 02:07, Joe Bogner <joebog...@gmail.com> wrote:

> dean, is this what you are describing?
>
> (let L (list 1 2 3)
> (setq L (append L (4)))
> (printsp L) )
>
>
> (1 2 3 4)
>
>
> The key to this is understanding how let works. It restores the prior
> value after execution. See http://software-lab.de/doc/refL.html#let
>
> Defines local variables. The value of the symbol sym - or the values of
> the symbols sym in the list of the second form - ***are saved** and the
> symbols are bound to the evaluated any arguments. The 64-bit version also
> accepts lst arguments in the second form; they may consist only of symbols
> and sublists, and match the any argument (destructuring bind). prg is
> executed, then the symbols ***are restored to their original values***.
>
>
>
> On Fri, Feb 10, 2017 at 3:22 PM, dean <deangwillia...@gmail.com> wrote:
>
>> Hi
>> I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
>> 'Some_atom)
>> which gets me a long way...
>> ...but what about list elements?
>>
>>
>> (setq L (0 0 0))
>> (de doit ()
>>#(let L (0 0 0)
>>   (setq L (insert '1 (remove '1 L) 2))
>>   (prinl "L is " L)
>>#)
>> )
>>
>> When I "setq" L this works but can I do it (somehow) when L is created
>> with "let"?
>>
>
>


Re: altering LOCAL list elements

2017-02-11 Thread dean
Here's the desired behaviour using the above code

: (setq L (0 0 0))
-> (0 0 0)
: (de doit ()
   #(let L (0 0 0)
  (setq L (insert '1 (remove '1 L) 2))
  (prinl "L is " L)
   #)
)
-> doit
: (doit)
L is 200
-> (2 0 0)

I was after (2 0 0) using let L i.e. the two lines commented out which
would replace the top setq... line
but no go and probably quite rightly. It just that (let A 3..(inc
'A)...allows A to have it's value altered but there doesn't seem to be a
way to bring inc/dec to bear on a list element in the same very influential
way.

On 11 February 2017 at 10:23, dean <deangwillia...@gmail.com> wrote:

> Hi Joh-tob & Joe
> With setq L.(0 0 0) gets changed to (2 0 0) i.e. the replace is done
> by index not matching value
> With let L...(0 0 0) stays at (0 0 0)
> I'd wanted the former in conjunction with let.
> Thank you for the suggestion re need...and the explanation re let.
> I can do this with setq but was just wondering if there was a way around
> "setting" let'd values more than once...like you can with let'd
> atoms...using inc and dec.
> I don't think you can but didn't think you could with atoms until inc and
> dec came back as an answer on this forum...hence this question :).
> Thank you for your advice and best regards
> Dean
>
>
>
> On 11 February 2017 at 02:07, Joe Bogner <joebog...@gmail.com> wrote:
>
>> dean, is this what you are describing?
>>
>> (let L (list 1 2 3)
>> (setq L (append L (4)))
>> (printsp L) )
>>
>>
>> (1 2 3 4)
>>
>>
>> The key to this is understanding how let works. It restores the prior
>> value after execution. See http://software-lab.de/doc/refL.html#let
>>
>> Defines local variables. The value of the symbol sym - or the values of
>> the symbols sym in the list of the second form - ***are saved** and the
>> symbols are bound to the evaluated any arguments. The 64-bit version also
>> accepts lst arguments in the second form; they may consist only of symbols
>> and sublists, and match the any argument (destructuring bind). prg is
>> executed, then the symbols ***are restored to their original values***.
>>
>>
>>
>> On Fri, Feb 10, 2017 at 3:22 PM, dean <deangwillia...@gmail.com> wrote:
>>
>>> Hi
>>> I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
>>> 'Some_atom)
>>> which gets me a long way...
>>> ...but what about list elements?
>>>
>>>
>>> (setq L (0 0 0))
>>> (de doit ()
>>>#(let L (0 0 0)
>>>   (setq L (insert '1 (remove '1 L) 2))
>>>   (prinl "L is " L)
>>>#)
>>> )
>>>
>>> When I "setq" L this works but can I do it (somehow) when L is created
>>> with "let"?
>>>
>>
>>
>


Re: altering LOCAL list elements

2017-02-11 Thread dean
This works too but I really want to remove setq from the middle of doit

: (de doit ()
   (let L (0 0 0)
  (setq L (insert '1 (remove '1 L) 2))
  (prinl "L is " L)
   )
)
-> doit
: (doit)
L is 200
-> (2 0 0)




On 11 February 2017 at 10:29, dean <deangwillia...@gmail.com> wrote:

> Here's the desired behaviour using the above code
>
> : (setq L (0 0 0))
> -> (0 0 0)
> : (de doit ()
>#(let L (0 0 0)
>   (setq L (insert '1 (remove '1 L) 2))
>   (prinl "L is " L)
>#)
> )
> -> doit
> : (doit)
> L is 200
> -> (2 0 0)
>
> I was after (2 0 0) using let L i.e. the two lines commented out which
> would replace the top setq... line
> but no go and probably quite rightly. It just that (let A 3..(inc
> 'A)...allows A to have it's value altered but there doesn't seem to be a
> way to bring inc/dec to bear on a list element in the same very influential
> way.
>
> On 11 February 2017 at 10:23, dean <deangwillia...@gmail.com> wrote:
>
>> Hi Joh-tob & Joe
>> With setq L.(0 0 0) gets changed to (2 0 0) i.e. the replace is done
>> by index not matching value
>> With let L...(0 0 0) stays at (0 0 0)
>> I'd wanted the former in conjunction with let.
>> Thank you for the suggestion re need...and the explanation re let.
>> I can do this with setq but was just wondering if there was a way around
>> "setting" let'd values more than once...like you can with let'd
>> atoms...using inc and dec.
>> I don't think you can but didn't think you could with atoms until inc and
>> dec came back as an answer on this forum...hence this question :).
>> Thank you for your advice and best regards
>> Dean
>>
>>
>>
>> On 11 February 2017 at 02:07, Joe Bogner <joebog...@gmail.com> wrote:
>>
>>> dean, is this what you are describing?
>>>
>>> (let L (list 1 2 3)
>>> (setq L (append L (4)))
>>> (printsp L) )
>>>
>>>
>>> (1 2 3 4)
>>>
>>>
>>> The key to this is understanding how let works. It restores the prior
>>> value after execution. See http://software-lab.de/doc/refL.html#let
>>>
>>> Defines local variables. The value of the symbol sym - or the values of
>>> the symbols sym in the list of the second form - ***are saved** and the
>>> symbols are bound to the evaluated any arguments. The 64-bit version also
>>> accepts lst arguments in the second form; they may consist only of symbols
>>> and sublists, and match the any argument (destructuring bind). prg is
>>> executed, then the symbols ***are restored to their original values***.
>>>
>>>
>>>
>>> On Fri, Feb 10, 2017 at 3:22 PM, dean <deangwillia...@gmail.com> wrote:
>>>
>>>> Hi
>>>> I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
>>>> 'Some_atom)
>>>> which gets me a long way...
>>>> ...but what about list elements?
>>>>
>>>>
>>>> (setq L (0 0 0))
>>>> (de doit ()
>>>>#(let L (0 0 0)
>>>>   (setq L (insert '1 (remove '1 L) 2))
>>>>   (prinl "L is " L)
>>>>#)
>>>> )
>>>>
>>>> When I "setq" L this works but can I do it (somehow) when L is created
>>>> with "let"?
>>>>
>>>
>>>
>>
>


Re: altering LOCAL list elements

2017-02-11 Thread dean
and use a local solution but don't think that I can

On 11 February 2017 at 10:38, dean <deangwillia...@gmail.com> wrote:

> This works too but I really want to remove setq from the middle of doit
>
> : (de doit ()
>(let L (0 0 0)
>   (setq L (insert '1 (remove '1 L) 2))
>   (prinl "L is " L)
>)
> )
> -> doit
> : (doit)
> L is 200
> -> (2 0 0)
>
>
>
>
> On 11 February 2017 at 10:29, dean <deangwillia...@gmail.com> wrote:
>
>> Here's the desired behaviour using the above code
>>
>> : (setq L (0 0 0))
>> -> (0 0 0)
>> : (de doit ()
>>#(let L (0 0 0)
>>   (setq L (insert '1 (remove '1 L) 2))
>>   (prinl "L is " L)
>>#)
>> )
>> -> doit
>> : (doit)
>> L is 200
>> -> (2 0 0)
>>
>> I was after (2 0 0) using let L i.e. the two lines commented out which
>> would replace the top setq... line
>> but no go and probably quite rightly. It just that (let A 3..(inc
>> 'A)...allows A to have it's value altered but there doesn't seem to be a
>> way to bring inc/dec to bear on a list element in the same very influential
>> way.
>>
>> On 11 February 2017 at 10:23, dean <deangwillia...@gmail.com> wrote:
>>
>>> Hi Joh-tob & Joe
>>> With setq L.(0 0 0) gets changed to (2 0 0) i.e. the replace is done
>>> by index not matching value
>>> With let L...(0 0 0) stays at (0 0 0)
>>> I'd wanted the former in conjunction with let.
>>> Thank you for the suggestion re need...and the explanation re let.
>>> I can do this with setq but was just wondering if there was a way around
>>> "setting" let'd values more than once...like you can with let'd
>>> atoms...using inc and dec.
>>> I don't think you can but didn't think you could with atoms until inc
>>> and dec came back as an answer on this forum...hence this question :).
>>> Thank you for your advice and best regards
>>> Dean
>>>
>>>
>>>
>>> On 11 February 2017 at 02:07, Joe Bogner <joebog...@gmail.com> wrote:
>>>
>>>> dean, is this what you are describing?
>>>>
>>>> (let L (list 1 2 3)
>>>> (setq L (append L (4)))
>>>> (printsp L) )
>>>>
>>>>
>>>> (1 2 3 4)
>>>>
>>>>
>>>> The key to this is understanding how let works. It restores the prior
>>>> value after execution. See http://software-lab.de/doc/refL.html#let
>>>>
>>>> Defines local variables. The value of the symbol sym - or the values of
>>>> the symbols sym in the list of the second form - ***are saved** and the
>>>> symbols are bound to the evaluated any arguments. The 64-bit version also
>>>> accepts lst arguments in the second form; they may consist only of symbols
>>>> and sublists, and match the any argument (destructuring bind). prg is
>>>> executed, then the symbols ***are restored to their original values***.
>>>>
>>>>
>>>>
>>>> On Fri, Feb 10, 2017 at 3:22 PM, dean <deangwillia...@gmail.com> wrote:
>>>>
>>>>> Hi
>>>>> I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
>>>>> 'Some_atom)
>>>>> which gets me a long way...
>>>>> ...but what about list elements?
>>>>>
>>>>>
>>>>> (setq L (0 0 0))
>>>>> (de doit ()
>>>>>#(let L (0 0 0)
>>>>>   (setq L (insert '1 (remove '1 L) 2))
>>>>>   (prinl "L is " L)
>>>>>#)
>>>>> )
>>>>>
>>>>> When I "setq" L this works but can I do it (somehow) when L is created
>>>>> with "let"?
>>>>>
>>>>
>>>>
>>>
>>
>


Re: altering LOCAL list elements

2017-02-11 Thread dean
BTW I left setq in the midlle of doit by accident...i.e I used it to work
out how to replace a list element by index not value as per the built-in
replace.

On 11 February 2017 at 10:38, dean <deangwillia...@gmail.com> wrote:

> and use a local solution but don't think that I can
>
> On 11 February 2017 at 10:38, dean <deangwillia...@gmail.com> wrote:
>
>> This works too but I really want to remove setq from the middle of doit
>>
>> : (de doit ()
>>(let L (0 0 0)
>>   (setq L (insert '1 (remove '1 L) 2))
>>   (prinl "L is " L)
>>)
>> )
>> -> doit
>> : (doit)
>> L is 200
>> -> (2 0 0)
>>
>>
>>
>>
>> On 11 February 2017 at 10:29, dean <deangwillia...@gmail.com> wrote:
>>
>>> Here's the desired behaviour using the above code
>>>
>>> : (setq L (0 0 0))
>>> -> (0 0 0)
>>> : (de doit ()
>>>#(let L (0 0 0)
>>>   (setq L (insert '1 (remove '1 L) 2))
>>>   (prinl "L is " L)
>>>#)
>>> )
>>> -> doit
>>> : (doit)
>>> L is 200
>>> -> (2 0 0)
>>>
>>> I was after (2 0 0) using let L i.e. the two lines commented out which
>>> would replace the top setq... line
>>> but no go and probably quite rightly. It just that (let A 3..(inc
>>> 'A)...allows A to have it's value altered but there doesn't seem to be a
>>> way to bring inc/dec to bear on a list element in the same very influential
>>> way.
>>>
>>> On 11 February 2017 at 10:23, dean <deangwillia...@gmail.com> wrote:
>>>
>>>> Hi Joh-tob & Joe
>>>> With setq L.(0 0 0) gets changed to (2 0 0) i.e. the replace is
>>>> done by index not matching value
>>>> With let L...(0 0 0) stays at (0 0 0)
>>>> I'd wanted the former in conjunction with let.
>>>> Thank you for the suggestion re need...and the explanation re let.
>>>> I can do this with setq but was just wondering if there was a way
>>>> around "setting" let'd values more than once...like you can with let'd
>>>> atoms...using inc and dec.
>>>> I don't think you can but didn't think you could with atoms until inc
>>>> and dec came back as an answer on this forum...hence this question :).
>>>> Thank you for your advice and best regards
>>>> Dean
>>>>
>>>>
>>>>
>>>> On 11 February 2017 at 02:07, Joe Bogner <joebog...@gmail.com> wrote:
>>>>
>>>>> dean, is this what you are describing?
>>>>>
>>>>> (let L (list 1 2 3)
>>>>> (setq L (append L (4)))
>>>>> (printsp L) )
>>>>>
>>>>>
>>>>> (1 2 3 4)
>>>>>
>>>>>
>>>>> The key to this is understanding how let works. It restores the prior
>>>>> value after execution. See http://software-lab.de/doc/refL.html#let
>>>>>
>>>>> Defines local variables. The value of the symbol sym - or the values
>>>>> of the symbols sym in the list of the second form - ***are saved** and the
>>>>> symbols are bound to the evaluated any arguments. The 64-bit version also
>>>>> accepts lst arguments in the second form; they may consist only of symbols
>>>>> and sublists, and match the any argument (destructuring bind). prg is
>>>>> executed, then the symbols ***are restored to their original values***.
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Feb 10, 2017 at 3:22 PM, dean <deangwillia...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Hi
>>>>>> I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
>>>>>> 'Some_atom)
>>>>>> which gets me a long way...
>>>>>> ...but what about list elements?
>>>>>>
>>>>>>
>>>>>> (setq L (0 0 0))
>>>>>> (de doit ()
>>>>>>#(let L (0 0 0)
>>>>>>   (setq L (insert '1 (remove '1 L) 2))
>>>>>>   (prinl "L is " L)
>>>>>>#)
>>>>>> )
>>>>>>
>>>>>> When I "setq" L this works but can I do it (somehow) when L is
>>>>>> created with "let"?
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>


Re: trouble reading non blocking space etc

2017-02-14 Thread dean
This is the closest I've got i.e. the first byte seems to go into B now but
then I'm in an endless loop with B's value stuck with that first byte.

(in "/home/me/test_fl.txt"
   (until (eof)
  (setq B (pipe (echo 1) (read)))
  (prinl B)
  (if (= (key) "x") (quit

On 14 February 2017 at 13:03, dean <deangwillia...@gmail.com> wrote:

> My mistakeI haven't done it at all and what is moreI'm not sure
> how you get the hex value (or decimal value) of the byte to decide what to
> do with it.
>
> On 14 February 2017 at 12:38, dean <deangwillia...@gmail.com> wrote:
>
>> Done it :)
>>
>> (in "/home/me/test_fl.txt"
>>(until (eof)
>>   (echo 1)
>>   (setq B (in NIL))
>>   (prinl B)
>>   (key)))
>>
>>
>> On 14 February 2017 at 12:26, dean <deangwillia...@gmail.com> wrote:
>>
>>> Looking a possible ways around this I saw this in the tutorial :)
>>>
>>> (in "/home/me/test_fl.txt"
>>>(until (eof)
>>>   (echo 1)
>>>   (key)))
>>>
>>> and it works great. My problem is I don't know how to
>>> capture (echo 1)  into a symbol's val.
>>>
>>>
>>> On 13 February 2017 at 23:03, dean <deangwillia...@gmail.com> wrote:
>>>
>>>> Thank you very much for this!
>>>> I tried (cd src; make tools) both from the command line...because of
>>>> "$"
>>>> and from within Picolisps RPL because of the parens.
>>>> I looked in src and there is just the utf2.c file.
>>>> When I do $ (cd src; make tools) from the command line I get...
>>>> $ (cd src; make tools)
>>>> *** Parse error in /home/me/picoLisp/src: Missing dependency operator
>>>> (Makefile:20)
>>>> *** Parse error: Need an operator in 'else' (Makefile:28)
>>>> *** Parse error: Missing dependency operator (Makefile:29)
>>>> *** Parse error: Need an operator in 'else' (Makefile:37)
>>>> etc.
>>>>
>>>> which looks like
>>>> the block beginning
>>>> ifeg ($(shell uname), Linux)
>>>> .
>>>> .
>>>> else
>>>> ifeg ($(shell uname, OpenBSD)
>>>> .
>>>> .
>>>> I'm the second i.e. OpenBSD option and know very nothing about
>>>> makefiles.
>>>> I'm on a 64 bit OS but am looking at two -m32 options in there.
>>>> That might well be ok but I thought I'd mention it.
>>>>
>>>> Best Regards
>>>> Dean
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On 13 February 2017 at 21:52, Alexander Burger <a...@software-lab.de>
>>>> wrote:
>>>>
>>>>> Hi Dean,
>>>>>
>>>>> > 6869 a074 6865 6972 3aa0 686f 7720 6172 6520 796f 750a
>>>>> > hi.their:.how are you.
>>>>> >
>>>>> > The following program...
>>>>> >
>>>>> > (in "/home/me/test_fl.txt"
>>>>> >(until (eof)
>>>>> >   (setq Ln (line T))
>>>>> >   (prinl Ln)))
>>>>> >
>>>>> > results in this
>>>>> >
>>>>> > hiനeir:ਯw are you
>>>>>
>>>>> OK, as you noticed in your other mail, PicoLisp can handle *only*
>>>>> UTF-8 input.
>>>>>
>>>>>
>>>>> > (load "@lib/import.l")
>>>>>
>>>>> This is probably not necessary here.
>>>>>
>>>>>
>>>>> > (in '("bin/utf8" "/home/me/test_fl.txt")
>>>>>
>>>>> Good, that's the right way!
>>>>>
>>>>>
>>>>> > bin/utf8: Can't exec
>>>>>
>>>>> Try this:
>>>>>
>>>>>$ (cd src; make tools)
>>>>>
>>>>> ♪♫ Alex
>>>>> --
>>>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>>>
>>>>
>>>>
>>>
>>
>


Re: trouble reading non blocking space etc

2017-02-14 Thread dean
Ok...It seems that (rd 1) doesn't work well with (until (eof) so I tried

(in "/home/me/test_fl.txt"
   (while (setq B (rd 1))
  (prinl (char B))
  (if (= (key) "x") (quit

and "while" testing the output of "rd 1" worked fine

On 14 February 2017 at 16:21, dean <deangwillia...@gmail.com> wrote:

> Ok Done it now including the decimal codes and I'd previously seen both
> hex and hax so...this should keep me busy for a while :).
>
> (in "/home/me/test_fl.txt"
>(until (eof)
>   (setq B (rd 1))
>   (prinl B  )
>   (if (= (key) "x") (quit
>
> On 14 February 2017 at 15:50, dean <deangwillia...@gmail.com> wrote:
>
>> This is the closest I've got i.e. the first byte seems to go into B now
>> but then I'm in an endless loop with B's value stuck with that first byte.
>>
>> (in "/home/me/test_fl.txt"
>>(until (eof)
>>   (setq B (pipe (echo 1) (read)))
>>   (prinl B)
>>   (if (= (key) "x") (quit
>>
>> On 14 February 2017 at 13:03, dean <deangwillia...@gmail.com> wrote:
>>
>>> My mistakeI haven't done it at all and what is moreI'm not sure
>>> how you get the hex value (or decimal value) of the byte to decide what to
>>> do with it.
>>>
>>> On 14 February 2017 at 12:38, dean <deangwillia...@gmail.com> wrote:
>>>
>>>> Done it :)
>>>>
>>>> (in "/home/me/test_fl.txt"
>>>>(until (eof)
>>>>   (echo 1)
>>>>   (setq B (in NIL))
>>>>   (prinl B)
>>>>   (key)))
>>>>
>>>>
>>>> On 14 February 2017 at 12:26, dean <deangwillia...@gmail.com> wrote:
>>>>
>>>>> Looking a possible ways around this I saw this in the tutorial :)
>>>>>
>>>>> (in "/home/me/test_fl.txt"
>>>>>(until (eof)
>>>>>   (echo 1)
>>>>>   (key)))
>>>>>
>>>>> and it works great. My problem is I don't know how to
>>>>> capture (echo 1)  into a symbol's val.
>>>>>
>>>>>
>>>>> On 13 February 2017 at 23:03, dean <deangwillia...@gmail.com> wrote:
>>>>>
>>>>>> Thank you very much for this!
>>>>>> I tried (cd src; make tools) both from the command line...because of
>>>>>> "$"
>>>>>> and from within Picolisps RPL because of the parens.
>>>>>> I looked in src and there is just the utf2.c file.
>>>>>> When I do $ (cd src; make tools) from the command line I get...
>>>>>> $ (cd src; make tools)
>>>>>> *** Parse error in /home/me/picoLisp/src: Missing dependency operator
>>>>>> (Makefile:20)
>>>>>> *** Parse error: Need an operator in 'else' (Makefile:28)
>>>>>> *** Parse error: Missing dependency operator (Makefile:29)
>>>>>> *** Parse error: Need an operator in 'else' (Makefile:37)
>>>>>> etc.
>>>>>>
>>>>>> which looks like
>>>>>> the block beginning
>>>>>> ifeg ($(shell uname), Linux)
>>>>>> .
>>>>>> .
>>>>>> else
>>>>>> ifeg ($(shell uname, OpenBSD)
>>>>>> .
>>>>>> .
>>>>>> I'm the second i.e. OpenBSD option and know very nothing about
>>>>>> makefiles.
>>>>>> I'm on a 64 bit OS but am looking at two -m32 options in there.
>>>>>> That might well be ok but I thought I'd mention it.
>>>>>>
>>>>>> Best Regards
>>>>>> Dean
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 13 February 2017 at 21:52, Alexander Burger <a...@software-lab.de>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi Dean,
>>>>>>>
>>>>>>> > 6869 a074 6865 6972 3aa0 686f 7720 6172 6520 796f 750a
>>>>>>> > hi.their:.how are you.
>>>>>>> >
>>>>>>> > The following program...
>>>>>>> >
>>>>>>> > (in "/home/me/test_fl.txt"
>>>>>>> >(until (eof)
>>>>>>> >   (setq Ln (line T))
>>>>>>> >   (prinl Ln)))
>>>>>>> >
>>>>>>> > results in this
>>>>>>> >
>>>>>>> > hiനeir:ਯw are you
>>>>>>>
>>>>>>> OK, as you noticed in your other mail, PicoLisp can handle *only*
>>>>>>> UTF-8 input.
>>>>>>>
>>>>>>>
>>>>>>> > (load "@lib/import.l")
>>>>>>>
>>>>>>> This is probably not necessary here.
>>>>>>>
>>>>>>>
>>>>>>> > (in '("bin/utf8" "/home/me/test_fl.txt")
>>>>>>>
>>>>>>> Good, that's the right way!
>>>>>>>
>>>>>>>
>>>>>>> > bin/utf8: Can't exec
>>>>>>>
>>>>>>> Try this:
>>>>>>>
>>>>>>>$ (cd src; make tools)
>>>>>>>
>>>>>>> ♪♫ Alex
>>>>>>> --
>>>>>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>


Re: trouble reading non blocking space etc

2017-02-14 Thread dean
Ok Done it now including the decimal codes and I'd previously seen both hex
and hax so...this should keep me busy for a while :).

(in "/home/me/test_fl.txt"
   (until (eof)
  (setq B (rd 1))
  (prinl B  )
  (if (= (key) "x") (quit

On 14 February 2017 at 15:50, dean <deangwillia...@gmail.com> wrote:

> This is the closest I've got i.e. the first byte seems to go into B now
> but then I'm in an endless loop with B's value stuck with that first byte

Re: trouble reading non blocking space etc

2017-02-15 Thread dean
Until those >128 characters messed me up...I was working with lines
but am sure I can adapt what you've writtenwhich looks very slick :)
...to cope with that by trapping the Line feed character and processing
the accumulated list
upto that point.
Thank you very much for your help.

On 15 February 2017 at 01:36, Lindsay John Lawrence <
lawrence.lindsayj...@gmail.com> wrote:

> If you are just working with bytes,  maybe you do not need to  'print' or
> 'symbolize'...
>
> : (in "test.txt" (while (rd 1) (wr @)))
>
> hi�theRE:�how are you
> -> 10
>
> ...or  filtering for graphic ascii and everything else to space...
>
> : (setq E '(let (C NIL) (in "test.txt" (while (rd 1) (setq C @) (if (and
> (< 32 C) (> 127 C)) (wr C) (wr 32))
> : (eval E)
> hi theRE: how are you -> 32
>
> ... channeling to a file
>
> : (out "chars.txt" (eval E))
> -> 32
> : (call 'cat "chars.txt")
> hi theRE: how are you -> T
>
> /Lindsay
>
>
>
>


trouble reading non blocking space etc

2017-02-13 Thread dean
Hi
Here's a test file with it's hex above

6869 a074 6865 6972 3aa0 686f 7720 6172 6520 796f 750a
hi.their:.how are you.

The following program...

(in "/home/me/test_fl.txt"
   (until (eof)
  (setq Ln (line T))
  (prinl Ln)))

results in this

hiനeir:ਯw are you

I tried this

(load "@lib/import.l")
(in '("bin/utf8" "/home/me/test_fl.txt")

at the top of the program but got...

bin/utf8: Can't exec

I couldn't see a utf8 in /bin or picoLisp/bin

I suspect it's the A0 and : that's messing things up but am not sure what
to do about it.
Perl handles this fine by default but not if I tell it to do utf-8 encoding
i.e.
$ perl read_fl2.pl
utf8 "\xA0" does not map to Unicode at read_fl2.pl line 5.
utf8 "\xA0" does not map to Unicode at read_fl2.pl line 5.
got character h [U+0068]
got character i [U+0069]
got character \ [U+005c]
got character x [U+0078]
got character A [U+0041]
got character 0 [U+0030]
got character t [U+0074]

Any help to sort this out would be much appreciated.


Re: altering LOCAL list elements

2017-02-11 Thread dean
>Does that explanation make sense?

Yes it does

>You can either destructivly change the car of a cell in the list or write
your own pop which keeps the same >cell at the head of the list (by
reassigning car parts appropiatly).

Thank you...this is the only way I know about at the moment that lets me
destroy the car and replace it with something new...as you say though it
creates a whole new AND GLOBAL list because of setq.
  (setq L (insert '1 (remove '1 L) 2))

Irrespective...thank you for your further advice.




On 11 February 2017 at 10:51, Joh-Tob Schäg <johtob...@gmail.com> wrote:

> List operations in Picolisp tend to be non destructive and constructive
> (they allocate new cells to get what you want) leaving old ones to be
> collected by gc.
> Am 11.02.2017 11:48 schrieb "Joh-Tob Schäg" <johtob...@gmail.com>:
>
>> I understand your problem now.
>>
>> You have think about cells in this case.
>>
>> When you inc a 'symbol the value part of the symbol-cell is changed.
>> [prop|val] represents a symbol in this case.
>> (inc '[NIL|5]) is [NIL|6]
>> The Symbol was changed destructivly. All earlier refernces to this cell
>> now evaluate to 6. That is because a cell evaluates to its value.
>>
>> If you push 88 on to a list. You do not get back the original list
>> changed but a new list which has a a cell with 88 in the beginning and
>> pointer to the old list in the cdr.
>> [1|pointer to 2nd cell] [2| pointer to 2nd cell ] [3|Nil] [Nil|Nil]
>> You save this list in to a symbol which now has the pointer to the first
>> element in it value slot.
>>
>> If you push 88 on to this list it looks like this:
>> [1|pointer to 2nd cell] [2| pointer to 2nd cell ] [3|Nil] [88|pointer to
>> first cell]
>> However your symbol L does not notice this change because it is still
>> pointing to the first cell.
>> To make it point to the head of the new list you need to setq the value
>> of L to the new head of the list.
>>
>> Does that explanation make sense?
>>
>> You can either destructivly change the car of a cell in the list or write
>> your own pop which keeps the same cell at the head of the list (by
>> reassigning car parts appropiatly).
>> Am 11.02.2017 11:29 schrieb "dean" <deangwillia...@gmail.com>:
>>
>>> Hi Joh-tob & Joe
>>> With setq L.(0 0 0) gets changed to (2 0 0) i.e. the replace is done
>>> by index not matching value
>>> With let L...(0 0 0) stays at (0 0 0)
>>> I'd wanted the former in conjunction with let.
>>> Thank you for the suggestion re need...and the explanation re let.
>>> I can do this with setq but was just wondering if there was a way around
>>> "setting" let'd values more than once...like you can with let'd
>>> atoms...using inc and dec.
>>> I don't think you can but didn't think you could with atoms until inc
>>> and dec came back as an answer on this forum...hence this question :).
>>> Thank you for your advice and best regards
>>> Dean
>>>
>>>
>>>
>>> On 11 February 2017 at 02:07, Joe Bogner <joebog...@gmail.com> wrote:
>>>
>>>> dean, is this what you are describing?
>>>>
>>>> (let L (list 1 2 3)
>>>> (setq L (append L (4)))
>>>> (printsp L) )
>>>>
>>>>
>>>> (1 2 3 4)
>>>>
>>>>
>>>> The key to this is understanding how let works. It restores the prior
>>>> value after execution. See http://software-lab.de/doc/refL.html#let
>>>>
>>>> Defines local variables. The value of the symbol sym - or the values of
>>>> the symbols sym in the list of the second form - ***are saved** and the
>>>> symbols are bound to the evaluated any arguments The 64-bit version also
>>>> accepts lst arguments in the second form; they may consist only of symbols
>>>> and sublists, and match the any argument (destructuring bind). prg is
>>>> executed, then the symbols ***are restored to their original values***

Re: altering LOCAL list elements

2017-02-11 Thread dean
Thank you

On 11 February 2017 at 11:51, Joh-Tob Schäg <johtob...@gmail.com> wrote:

> You can also explicitly change the car or cdr of a list cell.
> If you do a little diging in the docs you might find the functions.
> Am 11.02.2017 12:45 schrieb "dean" <deangwillia...@gmail.com>:
>
> > >Does that explanation make sense?
> >
> > Yes it does
> >
> > >You can either destructivly change the car of a cell in the list or
> write
> > your own pop which keeps the same >cell at the head of the list (by
> > reassigning car parts appropiatly).
> >
> > Thank you...this is the only way I know about at the moment that lets me
> > destroy the car and replace it with something new...as you say though it
> > creates a whole new AND GLOBAL list because of setq.
> >   (setq L (insert '1 (remove '1 L) 2))
> >
> > Irrespective...thank you for your further advice.
> >
> >
> >
> >
> > On 11 February 2017 at 10:51, Joh-Tob Schäg <johtob...@gmail.com> wrote:
> >
> > > List operations in Picolisp tend to be non destructive and constructive
> > > (they allocate new cells to get what you want) leaving old ones to be
> > > collected by gc.
> > > Am 11.02.2017 11:48 schrieb "Joh-Tob Schäg" <johtob...@gmail.com>:
> > >
> > >> I understand your problem now.
> > >>
> > >> You have think about cells in this case.
> > >>
> > >> When you inc a 'symbol the value part of the symbol-cell is changed.
> > >> [prop|val] represents a symbol in this case.
> > >> (inc '[NIL|5]) is [NIL|6]
> > >> The Symbol was changed destructivly. All earlier refernces to this
> cell
> > >> now evaluate to 6. That is because a cell evaluates to its value.
> > >>
> > >> If you push 88 on to a list. You do not get back the original list
> > >> changed but a new list which has a a cell with 88 in the beginning and
> > >> pointer to the old list in the cdr.
> > >> [1|pointer to 2nd cell] [2| pointer to 2nd cell ] [3|Nil] [Nil|Nil]
> > >> You save this list in to a symbol which now has the pointer to the
> first
> > >> element in it value slot.
> > >>
> > >> If you push 88 on to this list it looks like this:
> > >> [1|pointer to 2nd cell] [2| pointer to 2nd cell ] [3|Nil] [88|pointer
> to
> > >> first cell]
> > >> However your symbol L does not notice this change because it is still
> > >> pointing to the first cell.
> > >> To make it point to the head of the new list you need to setq the
> value
> > >> of L to the new head of the list.
> > >>
> > >> Does that explanation make sense?
> > >>
> > >> You can either destructivly change the car of a cell in the list or
> > write
> > >> your own pop which keeps the same cell at the head of the list (by
> > >> reassigning car parts appropiatly).
> > >> Am 11.02.2017 11:29 schrieb "dean" <deangwillia...@gmail.com>:
> > >>
> > >>> Hi Joh-tob & Joe
> > >>> With setq L.(0 0 0) gets changed to (2 0 0) i.e. the replace is
> > done
> > >>> by index not matching value
> > >>> With let L...(0 0 0) stays at (0 0 0)
> > >>> I'd wanted the former in conjunction with let.
> > >>> Thank you for the suggestion re need...and the explanation re let.
> > >>> I can do this with setq but was just wondering if there was a way
> > around
> > >>> "setting" let'd values more than once...like you can with let'd
> > >>> atoms...using inc and dec.
> > >>> I don't think you can but didn't think you could with atoms until inc
> > >>> and dec came back as an answer on this forum...hence this question :)
>


exit case body/prog/function

2017-01-19 Thread dean
I'd like to do this but am not sure if it's possible

( case 
   #= start of match clause
   (
   (prog
   (if () (EXIT THIS MATCH CLAUSE/PROG))
   (otherwise you'll execute this statement)
   )
  )
  #= end of match clause
  .
  .
  .
I also wonder if there's a similar... (if (T) (EXIT FUNCTION))


Re: exit case body/prog/function

2017-01-19 Thread dean
Thank you very much Joe.,,,I see what you mean and don't think I've been
clear enough.
I'll try and put a better example together.
It might be because of Lisps "everything returns a value" my constructs
aren't compatible.
We'll seeback soon.

On 19 January 2017 at 13:13, Joe Bogner <joebog...@gmail.com> wrote:

> dean, I would use unless.
>
> See this control structure below as an alternative to the prog/if
>
> : (setq Test1 1)
> -> 1
> : (case Test1 (1 (unless Test2 (prinl "true"
> true
> -> "true"
>
> : (setq Test2 "Nope")
> -> "Nope"
> : (case Test1 (1 (unless Test2 (prinl "true"
> -> NIL
>
>
>
> On Thu, Jan 19, 2017 at 7:55 AM, dean <deangwillia...@gmail.com> wrote:
>
>> I'd like to do this but am not sure if it's possible
>>
>> ( case 
>>#= start of match clause
>>(
>>(prog
>>(if () (EXIT THIS MATCH CLAUSE/PROG))
>>(otherwise you'll execute this statement)
>>)
>>   )
>>   #= end of match clause
>>   .
>>   .
>>   .
>> I also wonder if there's a similar... (if (T) (EXIT FUNCTION))
>>
>
>


Re: exit case body/prog/function

2017-01-19 Thread dean
Ok here we are...
This is the nearest I can get in PL with my limited familarity i.e. a very
flat structure

(setq Pg_bks 7)
(setq Lns_from_top 6)
(setq Do_it T)
(case 2
   (1 (prinl "in 1"))
   (2
  (if (> 2 Pg_blks)  (setq Do_it NIL))
  (if (> 6 Lns_from_top) (setq Do_it NIL))
  (if (Do_it) (prinl "yes doing a"))
  (if (Do_it) (prinl "yes doing b"))
  (if (Do_it) (prinl "yes doing c")))


I'm really after this.
I like it because of the very flat structure, I can write the "stop" rules
in a very natural way and One objection stops any further execution. I have
had some very experienced programmers comment that this style is
uglyMaybe but I find it very easy to understand/maintain.

#fn some_fn   or in lisp (prog..)
#   if cond1 then exit fn
#   if cond2 then exit fn
#   do a
#   do b
#   do c
#end fn

On 19 January 2017 at 14:01, dean <deangwillia...@gmail.com> wrote:

> Thank you very much Joe.,,,I see what you mean and don't think I've been
> clear enough.
> I'll try and put a better example together.
> It might be because of Lisps "everything returns a value" my constructs
> aren't compatible.
> We'll see....back soon.
>
> On 19 January 2017 at 13:13, Joe Bogner <joebog...@gmail.com> wrote:
>
>> dean, I would use unless.
>>
>> See this control structure below as an alternative to the prog/if
>>
>> : (setq Test1 1)
>> -> 1
>> : (case Test1 (1 (unless Test2 (prinl "true"
>> true
>> -> "true"
>>
>> : (setq Test2 "Nope")
>> -> "Nope"
>> : (case Test1 (1 (unless Test2 (prinl "true"
>> -> NIL
>>
>>
>>
>> On Thu, Jan 19, 2017 at 7:55 AM, dean <deangwillia...@gmail.com> wrote:
>>
>>> I'd like to do this but am not sure if it's possible
>>>
>>> ( case 
>>>#= start of match clause
>>>(
>>>(prog
>>>(if () (EXIT THIS MATCH CLAUSE/PROG))
>>>(otherwise you'll execute this statement)
>>>)
>>>   )
>>>   #= end of match clause
>>>   .
>>>   .
>>>   .
>>> I also wonder if there's a similar... (if (T) (EXIT FUNCTION))
>>>
>>
>>
>


Re: exit case body/prog/function

2017-01-19 Thread dean
Hi Alex
Thank you for confirming no return and the alternative.
Best Regards
Dean

On 19 January 2017 at 14:44, Alexander Burger <a...@software-lab.de> wrote:

> Hi Dean,
>
> > I'd like to do this but am not sure if it's possible
> >
> > ( case 
> >#= start of match clause
> >(
> >(prog
> >(if () (EXIT THIS MATCH CLAUSE/PROG))
> >(otherwise you'll execute this statement)
> >)
> >   )
> >   #= end of match clause
> >   .
> >   .
> >   .
> > I also wonder if there's a similar... (if (T) (EXIT FUNCTION))
>
> If I understand you right, you are looking for an exit out of a nested
> expression, like a 'return' statment in C or Java.
>
> Such a return does not exist, there is catch/throw for that
>
>(catch 'something
>   (for (..)
>  (if (..)
> (throw 'something)
> (elseStuff)
> ..
>
> Catch/throw is more general then 'return', but the latter can be emulated
> with
> it.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


using xml.l

2017-01-16 Thread dean
To get started I thought I'd try to list all the functions in xml.l using
PL and tried...
in "/home/me/xml.l" (while (line T) (prinl @)))
as a starting point but I'm not sure how you get past the third line which
is blank so
I reverted to what I know for now :)

$ perl -ne'$w='de';print if /.*$w /i' /home/me/xml.l
(de xml? (Flg)
(de xml (Lst N)
(de _xml_ (Lst)
(de _xml (In Char)
(de xmlEsc (L)
(de escXml (X)
(de xml$ (Lst)
(de body (Lst . @)
(de attr (Lst Key . @)
(de "xmlL" Lst
(de "xmlO" Lst
(de  ("N" . Lst)

Is there a very simple intro re how I'd manipulate my xml file using these
and how would I get this list using PL...'cos that's my tool of choice now
:)
Thank you in anticipation.


using xml.l contd

2017-01-16 Thread dean
Ok I found some good examples on Rosetta code i.e.

https://rosettacode.org/wiki/XML/Input#PicoLisp

and see that I have unbalanced xml.

I'm just wondering what the best tools to analyse this would be on openbsd.


Re: using xml.l

2017-01-16 Thread dean
Thank you very much for that.
Best Regards
Dean

On 16 January 2017 at 14:33, Alexander Burger <a...@software-lab.de> wrote:

> Hi Dean,
>
> > To get started I thought I'd try to list all the functions in xml.l using
> > PL and tried...
> > in "/home/me/xml.l" (while (line T) (prinl @)))
> > as a starting point but I'm not sure how you get past the third line
> which
> > is blank so
>
> Yes, 'line' returns NIL for blank lines, so the loop will stop.
>
>
> > I reverted to what I know for now :)
> >
> > $ perl -ne'$w='de';print if /.*$w /i' /home/me/xml.l
> > (de xml? (Flg)
> > (de xml (Lst N)
> > ...
>
> You could try this:
>
>(in "@lib/xml.l"
>   (until (eof)
>  (let? L (line)
> (and (= "(" (car L)) (prinl L)) ) ) )
>
> Outputs:
>
>(de xml? (Flg)
>(de xml (Lst N)
>(de _xml_ (Lst)
>(de _xml (In Char)
>(de xmlEsc (L)
>...
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: using xml.l

2017-01-16 Thread dean
I tried this on an xml file and it seems ideal re separating the tags and
data for processing
(in "fl.xml" (until (eof) (prinl (read

The input is stopping abruptly when I hit an isolated closed paren though
a).
which is resulting in
Bad input ')'
I'm just wondering how best to get around this



On 16 January 2017 at 14:53, dean <deangwillia...@gmail.com> wrote:

> Thank you very much for that.
> Best Regards
> Dean
>
> On 16 January 2017 at 14:33, Alexander Burger <a...@software-lab.de> wrote:
>
>> Hi Dean,
>>
>> > To get started I thought I'd try to list all the functions in xml.l
>> using
>> > PL and tried...
>> > in "/home/me/xml.l" (while (line T) (prinl @)))
>> > as a starting point but I'm not sure how you get past the third line
>> which
>> > is blank so
>>
>> Yes, 'line' returns NIL for blank lines, so the loop will stop.
>>
>>
>> > I reverted to what I know for now :)
>> >
>> > $ perl -ne'$w='de';print if /.*$w /i' /home/me/xml.l
>> > (de xml? (Flg)
>> > (de xml (Lst N)
>> > ...
>>
>> You could try this:
>>
>>(in "@lib/xml.l"
>>   (until (eof)
>>  (let? L (line)
>> (and (= "(" (car L)) (prinl L)) ) ) )
>>
>> Outputs:
>>
>>(de xml? (Flg)
>>(de xml (Lst N)
>>(de _xml_ (Lst)
>>(de _xml (In Char)
>>(de xmlEsc (L)
>>...
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: using xml.l

2017-01-16 Thread dean
>'read' cannot be used to parse an XML file, because it expects Lisp syntax

Re: using xml.l

2017-01-16 Thread dean
When I try to slurp the xml in I get
[fl.xml:1] !DOCTYPE -- Unbalanced XML

I'm assuming ":1" refers to the second line here...




I've looked at the xml tree using the firefox plugin "xml developer" and
it's indents look pretty uniform from the start to the end so I don'r
really know what I'm doing wrong.





On 16 January 2017 at 17:44, dean <deangwillia...@gmail.com> wrote:

> >'read' cannot be used to parse an XML file, because it expects Lisp
> syntax.
>
> Thank you for putting me straight on that.
>
> >You can then operate on the s-expr with all the list manipulation
> functions.
> >And/or use 'body' and 'attr' for convenience.
>
> That sounds really good...thank you very much
>
> On 16 January 2017 at 17:10, Alexander Burger <a...@software-lab.de> wrote:
>
>> On Mon, Jan 16, 2017 at 04:04:18PM +, dean wrote:
>> > I tried this on an xml file and it seems ideal re separating the tags
>> and
>> > data for processing
>> > (in "fl.xml" (until (eof) (prinl (read
>> >
>> > The input is stopping abruptly when I hit an isolated closed paren
>> though
>>
>> 'read' cannot be used to parse an XML file, because it expects Lisp
>> syntax.
>>
>>
>> > I'm just wondering how best to get around this
>>
>> "@lib/xm.l" or "@lib/xml.l" are for that.
>>
>> The function 'xml' slurps in a whole XML tree:
>>
>>: (load "@lib/xm.l")
>>
>>: (in "fl.xml" (and (xml?) (xml)))
>>-> (...)  # Get s-expr representing the XML
>>
>>: (pretty @)
>>   # Get pretty-printed output of the structure
>>
>> You can then operate on the s-expr with all the list manipulation
>> functions.
>> And/or use 'body' and 'attr' for convenience.
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: using xml.l

2017-01-16 Thread dean
I thought I was using xml.l since reading yesterday that xm.l was just in
for historic reasons sothat's a very good call on your part Alex and
sorry for my sloppiness :) and YES it works great!

On 16 January 2017 at 20:33, Alexander Burger <a...@software-lab.de> wrote:

> On Mon, Jan 16, 2017 at 07:48:52PM +0000, dean wrote:
> > When I try to slurp the xml in I get
> > [fl.xml:1] !DOCTYPE -- Unbalanced XML
> >
> > I'm assuming ":1" refers to the second line here...
> > 
> > 
>
> Yes, then please try "@lib/xml.l" instead of up "@lib/xm.l". It handles
> also
> comments and other things which are usually not in plain XML data files.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


executing a function + argument passed in as an argument to another function

2017-01-20 Thread dean
I seem to be able to do this by
(de some_fn (Canned_fn_and_arg..

and then executing the Canned_fn_and_arg inside some_fn by doing
((car Canned_fn) (car (cdr Canned_fn)))

Is this the right way or is there a slicker one?


Re: exit case body/prog/function

2017-01-19 Thread dean
Hi John
Yes...you're right...I was using an (if (or (stop test 1) (stop test 2))
(do nothing) (do all the stuff)
but your "unless" is much more direct.
Hi Alex
Yes I like that a lot!
Thank you both for your further help.
Best Regards
Dean

On 19 January 2017 at 17:02, Alexander Burger <a...@software-lab.de> wrote:

> On Thu, Jan 19, 2017 at 05:50:00PM +0100, Alexander Burger wrote:
> > Note that (setq Do_it NIL) is (off Do_it), and you could also use an
> 'or' for
> > the two equal consequences. Then the above becomes:
> >
> >(setq
> >   Pg_bks 7
> >   Lns_from_top 6
> >   Do_it T )
> >(case 2
> >   (1 (prinl "in 1"))
> >   (2
> >  (cond
> > ((or (> 2 Pg_blks) (> 6 Lns_from_top))
> >(off Do_it) )
> > (Do_it
> >(prinl "yes doing a")
> >(prinl "yes doing b")
> >(prinl "yes doing c") ) ) ) )
>
>
> Normally, of course, you will use 'let' instead of 'setq':
>
>(let (Pg_bks 7  Lns_from_top 6  Do_it T)
>   (case 2
>  (1 (prinl "in 1"))
>  (2
> (cond
>((or (> 2 Pg_blks) (> 6 Lns_from_top))
>   (off Do_it) )
>(Do_it
>   (prinl "yes doing a")
>   (prinl "yes doing b")
>   (prinl "yes doing c") ) ) ) ) )
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Subscribe

2016-11-11 Thread dean
I'm just wondering how you would capture the output from 'ls' to a list for
further processing.
I the first instance...I'd like to cd to a specified dir and caputure all
subdir names so that I can
cd to them in turn and process their pdf files, labelled 2005.pdf, 2006.pdf
etc

I've been playing around with the examples


I tried to bend this
https://rosettacode.org/wiki/Get_system_command_output#PicoLisp

: (in '(uname "-om") (line T))

to

: (in (call 'ls) (line T))

but no-go

Thank you in anticipation for your consideration and for

creating and supporting such an interesting little language.

BTW This is my very first lisp program let alone picolisp program.


Subscribe

2016-11-14 Thread dean
/*
I'm wondering where to cut the cake between prolog and pico/pilog
and thought I'd post a quick example to illustrate i.e.
initially I won't have individual values for variables
but a list of possibles and want the pc to pick the right values for me
using a system of (cast in stone) equations as a filter...just two in this
example.
Apparently for this to work I need to be use integers.
In reality the figures have decimal points so pico's fixed pt. maths looks
a good fit.

Any thoughts re how to approach this in pico/pilog much appreciated.
*/


:- use_module(library(clpfd)).

main :-
   Lsales = [100,200,300],
   Lcogs = [10,20,30],
   Lgross_profit = [160,180,200],
   member(Sales,Lsales),
   member(Cogs,Lcogs),
   member(Gross_profit,Lgross_profit),

   Ltax = [5,10,15],
   Lnet_profit = [100,170,300],
   member(Tax,Ltax),
   member(Net_profit,Lnet_profit),

   Gross_profit #= Sales - Cogs,
   Net_profit #= Gross_profit - Tax,

   format("Gross_profit ~w Sales ~w Cogs ~w\n",[Gross_profit,Sales,Cogs]),
   format("Net_profit ~w Gross_profit ~w Tax
~w\n",[Net_profit,Gross_profit,Tax]).

/*
?- main.
Gross_profit 180 Sales 200 Cogs 20
Net_profit 170 Gross_profit 180 Tax 10
true ;
false.
*/


As an asidere the output of 'Ls...is it possible to remove the double
quotes when printing the symbols or CARs of the resultant list?/
I read that initially the VAL is the same as the symbol...and it
iscomplete with double quotes.

Thank you in anticipation and best regards
Dean


Re: Subscribe

2016-11-15 Thread dean
Thank you for pointing that outI wasn't aware of that

On 15 November 2016 at 03:32, Brad Collins <b...@chenla.la> wrote:

>
> It would be helpful to use a subject line a little more
> descriptive than "Subscribe" :)
>
> I have been deleting all email with the "Subscribe" subject line
> without reading them because I thought they were just people
> trying to sub to the list.  I usually set up filters on
> lists to auto-delete any email with "Subscribe" or
> "Unsubscribe", I'm glad I hadn't gotten around to it yet on
> this list
>
> dean writes:
>
> > /*
> > I'm wondering where to cut the cake between prolog and pico/pilog
> > and thought I'd post a quick example to illustrate i.e.
> > initially I won't have individual values for variables
> > but a list of possibles and want the pc to pick the right values for me
> > using a system of (cast in stone) equations as a filter...just two in
> this
> > example.
> > Apparently for this to work I need to be use integers.
> > In reality the figures have decimal points so pico's fixed pt. maths
> looks
> > a good fit.
> >
> > Any thoughts re how to approach this in pico/pilog much appreciated.
> > */
> >
> >
> > :- use_module(library(clpfd)).
> >
> > main :-
> >Lsales = [100,200,300],
> >Lcogs = [10,20,30],
> >Lgross_profit = [160,180,200],
> >member(Sales,Lsales),
> >member(Cogs,Lcogs),
> >member(Gross_profit,Lgross_profit),
> >
> >Ltax = [5,10,15],
> >Lnet_profit = [100,170,300],
> >member(Tax,Ltax),
> >member(Net_profit,Lnet_profit),
> >
> >Gross_profit #= Sales - Cogs,
> >Net_profit #= Gross_profit - Tax,
> >
> >format("Gross_profit ~w Sales ~w Cogs ~w\n",[Gross_profit,Sales,
> Cogs]),
> >format("Net_profit ~w Gross_profit ~w Tax
> > ~w\n",[Net_profit,Gross_profit,Tax]).
> >
> > /*
> > ?- main.
> > Gross_profit 180 Sales 200 Cogs 20
> > Net_profit 170 Gross_profit 180 Tax 10
> > true ;
> > false.
> > */
> >
> >
> > As an asidere the output of 'Ls...is it possible to remove the double
> > quotes when printing the symbols or CARs of the resultant list?/
> > I read that initially the VAL is the same as the symbol...and it
> > iscomplete with double quotes.
> >
> > Thank you in anticipation and best regards
> > Dean
>
>
> --
> Brad Collins
> +855 010628234 | b...@chenla.la | Cambodia
> twitter: http://twitter.com/deerpig | github: http://github.com/deerpig
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


typo in tutorial re 'till' ?

2016-11-23 Thread dean
Not a big deal but... it seems there is one too many ')' on the end
resulting in bad input rather than "fact"
: (in "@doc/fun.l" (from "(de ") (till " " T)))
-> "fact"


stuck re quote

2016-11-21 Thread dean
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.


Re: typo in tutorial re 'till' ?

2016-11-23 Thread dean
Hi Alex
You're very welcome,

On 23 November 2016 at 10:53, Alexander Burger <a...@software-lab.de> wrote:

> On Wed, Nov 23, 2016 at 09:52:32AM +0000, dean wrote:
> > resulting in bad input rather than "fact"
> > : (in "@doc/fun.l" (from "(de ") (till " " T)))
>
> Thanks Dean! Fixed in next release.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


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 <joebog...@gmail.com> wrote:

> On Tue, Nov 22, 2016 at 5:29 AM, dean <deangwillia...@gmail.com> 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 <deangwillia...@gmail.com> 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
> >
> >
>

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 <deangwillia...@gmail.com> 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
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 <joebog...@gmail.com> 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 <deangwillia...@gmail.com> 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
>


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 <a...@software-lab.de> 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: iterate over list until you find a match

2016-11-24 Thread dean
If I isolate the following line... I get T as undefined

: (T (== 1 1) T)
!? (T (== 1 1) T)
T -- Undefined

Whereas...inside the function

(de mmbr (Trgt L)
   (for Ele L
  #(T (== Ele Trgt) T)
  (T (== 1 1) T)
   )
)

: (mmbr 'B '(A B C))
-> T
: (mmbr 'D '(A B C))
-> T

it works fine.
I'm not sure how the first T acts as a function on the next 2 arguments
(== 1 1) and T but see that there's an implied AND between the two.

i.e. I'm assuming this is a...
"A list is evaluated as a function call, with the CAR as the function
and the CDR the arguments to that function. These arguments are in turn
evaluated according to these three rules."
..situation

Any help to understand what's happening would be much appreciated
Best Regards
Dean


On 23 November 2016 at 21:24, dean <deangwillia...@gmail.com> wrote:

> Alex
> Thank you very much for this.
> Best Regards
> Dean
>
> On 23 November 2016 at 21:00, Alexander Burger <a...@software-lab.de>
> wrote:
>
>> Hi Dean,
>>
>> > I'm just wondering what my options are re doing this
>> >
>> > (de mmbr (Trgt L)
>> >(for Ele L
>> >   (if (== Ele Trgt) (println "found so exit with true")
>> > (println "try next")
>> >   )
>> >)
>> >(prinl "list exhausted so return false")
>> > )
>> >
>> > (mmbr 'B '(A B C))
>> >
>> > I only know how to iterate over lists using for but don't know how to
>> exit
>> > for.
>>
>> For simply finding an element in a list, you can use 'member' or 'memq'
>>
>>(memq 'B '(A B C))
>>
>> It returns the restlist, or NIL if not found.
>>
>>
>> To implement it yourself, you could do
>>
>>(de mmbr (Trgt L)
>>   (for Ele L
>>  (T (== Ele Trgt) T) ) )
>>
>>: (mmbr 'B '(A B C))
>>-> T
>>
>>: (mmbr 'D '(A B C))
>>-> NIL
>>
>>
>> > I also saw find...but wasn't sure exactly how I'd apply that.
>>
>>: (find '((X) (== X 'B)) '(A B C))
>>-> B
>>
>>
>> > BTW which is the most efficient loop in Picolisp from an execution
>> > perspective?
>>
>> I would say 'while' and 'until', or 'do' for counted loops.
>>
>> You can experiment with 'bench' to compare the relative speeds.
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: iterate over list until you find a match

2016-11-24 Thread dean
No you didn't misunderstand AlexI guessed the necessity for "for" when
the extracted line gave an error but didn't understand why. Your referral
to "for"s documentation explained though I had to play with some examples
to drum it in :).  Cristophe's examples were very helpful too because
although I suppose I understand "if true then exit for" in the middle of a
loop I need a lot more exposure to the lisp and picolisp way of doing
things. The above discussion between the two of you is certainly giving me
that exposure . Thank you.
Dean

On 24 November 2016 at 17:10, Alexander Burger <a...@software-lab.de> wrote:

> Hi Christophe,
>
> > >> : (T (== 1 1) T)
> > >> !? (T (== 1 1) T)
> > >> T -- Undefined
> >
> > Hi Alex, I'm not sure that you understood Dean's question.
> > Or maybe I didn't understand your answer.
>
> Not sure. I hope I didn't misunderstand ;)
>
>
> > What Dean did:
> > To understand your definition of mmbr, Dean extracted this line:
> > (T (== 1 1) T)
> > from the «for». Bad luck, the «for» function is what is called in some
> lisps
> > a «special form»: its arguments are not evaluated.
> > I think that in picoLisp it's called an f-expression.
>
> Right. An "FEXPR function", to be exact.
>
> However, the expressions in the *body* of 'loop', 'for' and other flow
> functions are normal s-expressions evaluated the normal way, one after
> the other, *but* with special handling if the CAR is T or NIL (exit
> conditions).
>
>
> > and done «manually».
> >
> > Some examples in picoLisp:
> >
> > : (de f (x) x)  # could have been defined with setq or set
>
> Side note, Please don't forget upper case here! (de f (X) X)
>
>
>
> > The «for» function kind of inspects its args to find «clauses»
> > and treat them specially, not as usual function calls.
> > That's why brutally extracting them from
> > the «for» construct doesn't work.
>
> Exactly.
>
>
> > An example of this kind is the «let» construct:
> >
> > : (let (X "Hello" Y "world") (prinl X " " Y))
> > Hello world
> > Here X is not a function but a symbol to which "Hello" is bound.
>
> Yes, 'let' is good example.
>
> In summary: As data and code are equivalent, it depends on the context
> what it is.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: solving for pilog variables

2016-11-27 Thread dean
Oopslet me try this

(-> @X) in place of @X in the lisp clause


On 27 November 2016 at 16:38, dean <deangwillia...@gmail.com> wrote:

> In preparation to do a predicate 'minus' I thought I see how to use lisp
> '-' within pilog.
> The first statement works re getting a 100% lisp calculation out to pilog
> but
> I think I need to pass in pilog variables and apply - to them...unless
> pilog has a -.
> Many apologies if I should know how to do this.
>
>
> : (prove (goal '(   (^ @X (- 4 2))  (equal @A 4)  (equal @B 2)
> )))
> -> ((@X . 2) (@A . 4) (@B . 2))
>: (prove (goal '(   (^ @X (- @A @B))  (equal @A 4)  (equal @B
> 2) )))
>  -> NIL
>
>
> On 27 November 2016 at 08:46, dean <deangwillia...@gmail.com> wrote:
>
>> Ok I'll keep trying and thank you for the pointers.
>> Best Regardsd
>> Dean
>>
>> On 27 November 2016 at 07:33, Alexander Burger <a...@software-lab.de>
>> wrote:
>>
>>> Hi Dean,
>>>
>>> > #(prove (goal '(equal 3 @X)   ))
>>>
>>> 'goal' needs a list of clauses:
>>>
>>>: (prove (goal '((equal 3 @X
>>>-> ((@X . 3))
>>>
>>>
>>> > #: (prove (goal '( (equal 3 @X) (member @X (1 2 4))   )))
>>> > #-> NIL
>>> > #: (prove (goal '( (equal 3 @X) (member @X (1 2 3))   )))
>>> > #-> ((@X . 3))
>>>
>>> OK
>>>
>>>
>>> > #(prove (goal '(
>>> > #(equal @Profit (- @Sales @Cogs))
>>>
>>> Did you define a '-' predicate?
>>>
>>> ♪♫ Alex
>>> --
>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>
>>
>>
>


Re: solving for pilog variables

2016-11-27 Thread dean
In preparation to do a predicate 'minus' I thought I see how to use lisp
'-' within pilog.
The first statement works re getting a 100% lisp calculation out to pilog
but
I think I need to pass in pilog variables and apply - to them...unless
pilog has a -.
Many apologies if I should know how to do this.


: (prove (goal '(   (^ @X (- 4 2))  (equal @A 4)  (equal @B 2)
)))
-> ((@X . 2) (@A . 4) (@B . 2))
   : (prove (goal '(   (^ @X (- @A @B))  (equal @A 4)  (equal @B
2) )))
 -> NIL


On 27 November 2016 at 08:46, dean <deangwillia...@gmail.com> wrote:

> Ok I'll keep trying and thank you for the pointers.
> Best Regardsd
> Dean
>
> On 27 November 2016 at 07:33, Alexander Burger <a...@software-lab.de>
> wrote:
>
>> Hi Dean,
>>
>> > #(prove (goal '(equal 3 @X)   ))
>>
>> 'goal' needs a list of clauses:
>>
>>: (prove (goal '((equal 3 @X
>>-> ((@X . 3))
>>
>>
>> > #: (prove (goal '( (equal 3 @X) (member @X (1 2 4))   )))
>> > #-> NIL
>> > #: (prove (goal '( (equal 3 @X) (member @X (1 2 3))   )))
>> > #-> ((@X . 3))
>>
>> OK
>>
>>
>> > #(prove (goal '(
>> > #(equal @Profit (- @Sales @Cogs))
>>
>> Did you define a '-' predicate?
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: solving for pilog variables

2016-11-27 Thread dean
Joe
Yes that's cracked it! I can see you've given values to @A and @B before
solving for @C but in Prolog I wasn't aware that the order mattered...There
again the calculation is being done in Lisp.
As a result of Alex's response this morning I added more parenthesis and
that seemed to solve what I was doing last night. I'll have to check you're
level of bracketing against mine.

Alex
I'm just trying to get Profit from Sales - Cogs and was struggling to
produce a minus predicate in pilog i.e. harnessing picolisps '-'. Sorry for
not being clear.

The problem is...for each item...Sales, Profit etc...I'll rarely have a
single value to work with ...just a list... so the formulae do more than
just get an end result...they also choose which of the numbers in the
various lists "work" together.

Thank you both for your examples. That's really helped.
Best Regards
Dean


On 27 November 2016 at 17:59, Alexander Burger <a...@software-lab.de> wrote:

> Hi Dean
>
> On Sun, Nov 27, 2016 at 05:42:21PM +, dean wrote:
> > (prove (goal '(   (^ @X (- (-> @A) (-> @B) )) (equal @A 4) (equal @B 2)
> )))
> > -> NIL
> >
> > -> wasn't the "one" in this case
>
> I'm not sure I understand the problem, but the most natural way for a
> diff predicate is perhaps
>
>: (be - (@A @B @Diff)
>   (^ @Diff (- (-> @A) (-> @B))) )
>-> -
>
>: (? @X 7  @Y 3  (- @X @Y @Res))
> @X=7 @Y=3 @Res=4
>
>:  (? (- 10 3 @X))
> @X=7
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


  1   2   >