Unsubscribe

2019-06-25 Thread JmageK
Good bye JmageK  :-(
You are now unsubscribed



JmageK
-- 
Securely sent with Tutanota

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


Re: Image processing, getting started?

2019-06-20 Thread JmageK
Jun 20, 2019, 12:20 PM by gpor...@yahoo.com:

> Hi!
>
> This is cool!
>
> Maybe you need to convert the images to PPM first? Or you can create or use 
> exisiting C library to get the right format you want :)
>
>
Yeah, PPM is a simple format. But for now I will try working without converting 
1st. Then perhaps, will look into libraries and conversion stuff. Thanks for 
the suggestion.


JmageK
--
Securely sent with Tutanota




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


Re: Image processing, getting started?

2019-06-20 Thread JmageK
Jun 20, 2019, 12:23 PM by a...@software-lab.de:

> On Thu, Jun 20, 2019 at 08:46:13AM +0200, Alexander Burger wrote:
>
>> (in "file"
>>  (make
>>  (do (car (info "file"))
>>  (link (rd 1)) ) ) )
>>
> Sorry, this is unnecessarily complex.
>
Right, but good to know there's a built in way to get file Meta data.
> Better is
>  (in "file"
>  (make
>  (while (rd 1)
>  (link @) ) ) )
>
Awesome, due to while (link @) works instead of needing (link (rd 1)).
Thanks! I think I'm sufficiently covered to get started.

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


Image processing, getting started?

2019-06-19 Thread JmageK
Hi, all!
I was recently thinking, 'How can you do image processing in picolisp' Like 
reading a file, changing some color values, etc.
I tried a basic PNG & jpg file. Using rd it does read but I'm getting binary 
output in terminal. And if I try it for a high value (when using jpg) pil 
crashes
: (in"file.jpg"(do 9 (prinl (rd]or
: (in"file.jpg"(do 40(PR(rd]For now just knowing how to read the file contents 
as an array of color values like if rgb then (255 23 123 23 1 0 44 65..) would 
be sufficient, but a better way is always welcome. I would be testing with jpg 
or PNG.
JmageK
-- 
Securely sent with Tutanota

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


Re: Use let variables inside match function

2019-06-15 Thread JmageK
Jun 15, 2019, 2:55 PM by a...@software-lab.de:

> (copy '@) is a no-op. 'copy' only copies the top level *cells* of a *list*. 
> '@'
> is a symbol. But with 'cons' it is not needed anyway, as 'cons' makes a new
> cell.
>
Yes, of cource! The doc does say it returns atoms unchanged. It's virtually the 
same (cons '@) The tidbit about it being a no-op was new. Guess I can consider 
it instead of (wait 0) for a no-op :D


> Yes, this is fine, but why start the whole machinery of 'copy' in (copy '(@))
> when just (cons '@) does the same (i.e. create a single new cell with '@' in 
> its
> CAR)?
>
Finding different ways to do something, So you know which ones to not use ;).


JmageK
--
Securely sent with Tutanota



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


Re: Use let variables inside match function

2019-06-15 Thread JmageK


Jun 15, 2019, 1:57 PM by a...@software-lab.de:

> will concatenate the rest to the cell (@). This works well if called only a
> single time (e.g. in the REPL), but is not desirable if it is in a function
> definition.
>
Right! It hanged the REPL on a 2nd function call
> Instead, you could call the non-destructive pendant of 'conc', which is
> 'append':
>
>  (append '(@) (chop S) '(@))
>
> but this is less efficient because it copies not only (@) but also the result 
> of
> the 'chop' (which in turn does not *need* to be copied as it is just freshly
> created and not shared anywhere.
>
>
I guess the inefficiency of copying the whole lists can be mitigated partially 
by passing a copy of '@ to conc I tested & it works fine across function calls. 
But then may as well use cons solution.


  (cons (copy'@) (conc (chop "Si")'(@)))
or 
  (conc (copy '(@)) (chop "Si")'(@))

> So I would say that
>  (conc (cons '@) (chop S) '(@))
>
> or alternatively
>  (cons '@ (conc (chop S) '(@))
> is the best
>
Yeah, this is straight forward. Originally, I assumed it was just a different 
way to do it, good to know. Thanks!

JmageK
--
Securely sent with Tutanota



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


Re: Use let variables inside match function

2019-06-15 Thread JmageK
Jun 15, 2019, 1:31 PM by jma...@tuta.io:

>> The shortest and fastest way is probably:
>> : (conc (cons '@) (chop S) '(@))
>> -> (@ "t" "s" "t" @)
>>
> Basically (cons '(@)(chop S)'(@))
> Neat solution. Thanks!
>
I mean (conc '(@)(chop S)'(@))

JmageK
--
Securely sent with Tutanota


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


Re: Use let variables inside match function

2019-06-15 Thread JmageK
Jun 15, 2019, 11:19 AM by a...@software-lab.de:

>  : (make (link '@) (mapc link (chop S)) (link '@))
>  -> (@ "t" "s" "t" @)
>
> or better
>  : (make (link '@) (chain (chop S)) (link '@))
>  -> (@ "t" "s" "t" @)
>
> The shortest and fastest way is probably:
>  : (conc (cons '@) (chop S) '(@))
>  -> (@ "t" "s" "t" @)
>
Basically (cons '(@)(chop S)'(@))
Neat solution. Thanks!

JmageK
--
Securely sent with Tutanota

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


Use let variables inside match function

2019-06-14 Thread JmageK
I know I can do this
: (match '(@ ~(chop "ts") @) (chop "tst"))
-> T
But i want to do the following, which doesn't work
: (Let S "tst"
   (match (list '@ (mapcar any (chop S)) '@)
     (chop "1st tst nil") ) )
-> NIL

JmageK
-- 
Securely sent with Tutanota

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


Re: Run a function whenever a request for a file arrives on the picolisp web server

2019-06-07 Thread JmageK
Jun 7, 2019, 7:31 PM by a...@software-lab.de:

> On Fri, Jun 07, 2019 at 03:39:12PM +0200, JmageK wrote:
>
>> Why is the dot neccesary for the subexpression to be bound, is it a general
>> rule that's documented somewhere?
>>
>
> I would say it is a general rule, following from the (CAR . CDR) principle of
> Lisp data.
>
This cons thing gets me, always!
> In our case, the CAR is 'cond' and the CDR is @X
>
> Without the dot (cond @X) is filled to
>
> (cond (((match ...
>
Okay so this step is where it becomes mandatory to use a dot.
> while *with* the dot it becomes
>
> (cond . (((match ...
>
> which is the same as
>
> (cond ((match ...)))
>
> which in turn is what we need here.
>
>
Otherwise it won't work(previous version)
Now it makes sense. Apparently, it's the little stuff that bugs the most. 
Thanks for the explanation!

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


Re: Run a function whenever a request for a file arrives on the picolisp web server

2019-06-07 Thread JmageK



> Thus, '@X' gets bound to
>
>  (((match '("-" @X "." "h" "t" "m" "l") U)
>  (and *SesId (timeout *Timeout))
>  ... ) ) ) )
>
> Note the additional list level, as 'match' binds its parameters to lists!
>
> So we need the dot in
>
>  (out *HtSock (cond . @X))
>
> so that this subexpression gets properly restored.
>
Why is the dot neccesary for the subexpression to be bound, is it a general 
rule that's documented somewhere?

And thanks for the explanation & help. Now it works perfectly well. Hope not 
bugging too much, haha 😅.


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


Re: Run a function whenever a request for a file arrives on the picolisp web server

2019-06-07 Thread JmageK
Jun 7, 2019, 3:49 PM by a...@software-lab.de:

> Hi JmageK,
>
>> My question is how to have picolisp run the ana function whenever a request
>> for a file or another html page arrives when it's running as a generic 
>> server.
>>
>
> Usually I log only new sessions, by loading @lib/app.l in production
> applications. This logs with 'msg' calls at the end of that file, the first 
> one
> when the server is started, and then once for each new session.
>
I checked @lib/app.l it looks cool
> If you want to log *every* access, you could do that by patching 'http', e.g.
> with
>
I tried the patch it logs but gets some errors and fails to server any file

#This is f2.l file 
(load'@lib/http.l'@lib/xhtml.l)

(de ana ()
   (out "+log.txt" (prinl *Url " " (pack *Agent) " "*Referrer " "*Adr " " (time 
(time )
(patch http '(out *HtSock (cond @X))
  (fill
 '(prog
    (ana)
    (out *HtSock (cond @X)) ) ) )
(de main()
   (html 0 "title" "lib.css" ""
  ( () "header 1") (ana) ) )
(server (format (opt)) "!main")

#start server at port 8090
$ pil f2.l 8090 +

#Visit localhost in a web browser
localhost:8090

#I get no data sent error in browser and the connection stuck
#on the server side the following one

!? ((match '("-" @X "." "h" "t" "m" "l") U) (and *SesId (timeout *Timeout)) 
(apply try L 'html> (extern (ht:Pack @X T
NIL -- Undefined
?
I'm unable to properly check which one is NIL--data gets corrupt on terminal 
when typing, I think it's html> 


>  (patch http '(out *HtSock (cond @X))
>  (fill
>  '(prog
>  (ana)
>  (out *HtSock (cond @X)) ) ) )
>
The patch is a nice function. I'm having a hard time understanding this entire 
code. Can you explain how it works? What gets bound to @X? Thanks!

JmageK


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


Run a function whenever a request for a file arrives on the picolisp web server

2019-06-07 Thread JmageK
This is the minimal reproducible code example for my current picolisp webpage.

(load'@lib/http.l'@lib/xhtml.l)
(de ana()
  (out "+log.txt" (prinl *Url " " (pack *Agent) " "*Adr " " (time (time )
(de main()  (html 0 "Analytics" "@lib.css"() (ana) ) )
(de go()
  (server 8080 "!main") )

$ pil analytics.l -go

It logs url, agent, & ip address when someone visits this page.

My question is how to have picolisp run the ana function whenever a request for 
a file or another html page arrives when it's running as a generic server.

#load file containing ana function$ pil @lib/http.l --server 8080 ana.l
$ curl localhost:8080/tst.html
#log ip, agent, url in log.txt$ localhost:8080/n.txt 
#log ip, agent, url in log.txt


JmageK
-- 
Securely sent with Tutanota

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


Re: Modyfying numbers inside function/variables

2019-05-12 Thread JmageK
Thanks for the explanation and reference! It makes sense. 

Jmage
-- 
Securely sent with Tutanota



May 13, 2019, 10:32 AM by a...@software-lab.de:

> Hi JmageK,
>
> > The previous mail quizzed me about, the (set (nth u 5) 1000) part.
> > I understand it basically setting a value at a certain place like u[5] = 
> >1000
>
>> in c like languages. nth returns a list starting from count and set evaluates
>> then sets the value of variable.
>>
>
> The important point to understand here is that a "variarle" in PicoLisp can
> either be a symbol or a cell in a list.
>
> >From doc/ref.html#fun, primary data types:
>
>  var - Variable: Either a symbol or a cons pair
>
>
>> : (cdadr (cdadr incM))-> (0)
>>
>
> This returns a single cell, which may then destructively modified with 'set',
> 'inc', 'pop' or whatever function accepts a 'var' argument.
>
>
> Internal background: 'set' gets a pointer to a part of a cell. For a list cell
> this it
>
>  |
>  V
>  +-+-+
>  | CAR | CDR |
>  +-+-+
>
> i.e. the CAR if a cell, while for a symbol it is
>
>  |
>  V
>  +-+-++-+-+
>  | | VAL ||'cba'|'fed'|
>  +-+-++-+-+
>
> i.e. the VAL (value) of a symbol.
>
> ☺/ A!ex
>
> -- 
> UNSUBSCRIBE: mailto:> picolisp@software-lab.de 
> <mailto:picolisp@software-lab.de>> ?subject=Unsubscribe
>


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


Modyfying numbers inside function/variables

2019-05-12 Thread JmageK
 The previous mail quizzed me about, the (set (nth u 5) 1000) part.
 I understand it basically setting a value at a certain place like u[5] = 1000 
in c like languages. nth returns a list starting from count and set evaluates 
then sets the value of variable. But, not sure why this is actually possible to 
do.
: (setq u (range 1 10)
-> (1 2 3 4 5 6 7 8 9 10)
: (set (nth u 5) 1000)
-> 1000
: u
-> (1 2 3 4 1000 6 7 8 9 10)


That also reminded me of a similar question I had about (0)
: (de incM ()
   (do 8
  (printsp 0)
  (inc (cdadr (cdadr incM))) ) )
: (cdadr (cdadr incM))-> (0)

: (incM)
0 1 2 3 4 5 6 7 -> 8
: (incM)
8 9 10 11 12 13 14 15 -> 16

How does the number get modified if it's not a symbol? [(sym? (0))-> returns 
NIL]
I have seen it for symbols and their values but don't understand this one.
  Does it have something to do with the basic cell structure? (0)->(0  . 
NIL)->(car . cadr)
 The cadr of the current cell points to the next cell and we modify the value 
at car of the current cell in list.
That probably also explains the 1st code

#The below code also reinforces it, I think.
Modifing the number inside the function if it is '(0)' works but not when it's 
'0'. Is it due to the (0 . NIL) cell distinction?
: (cdadr (cdadr incM))
-> (0)
: (set @ 60)
-> 60
: (cdadr (cdadr incM))
-> (60)
: (set (car @) 90)
? error variable expected 

# It's worth noting i can modify the counter for do loop without any issue like 
the 1st nth example.
: (set (cdr (cadr incM)) 5)
-> 5
: incM
-> (NIL (do 5 (printsp 60)(Inc (cdadr (cdadr incM)

JmageK
-- 
Securely sent with Tutanota

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


Re: Behavior of sort

2019-05-04 Thread JmageK
Copy appears to be most reliable as it does not modify the original list. Maybe 
a tiny bit slower than ->(setq L (sort L))

: (setq L (3 2 1 4 9 0]
-> (3 2 1 4 9 0)

: (sort (copy L]
-> (0 1 2 3 4 9)
: L
-> (3 2 1 4 9 0) 

: (setq L (sort L]
-> (0 1 2 3 4 9)
: L-> (0 1 2 3 4 9)

JmageK
-- 
Securely sent with Tutanota



May 4, 2019, 8:10 PM by a...@software-lab.de:

> Hi  Kashyap,
>
>> I noticed an odd behavior of sort -
>> (setq L '((2) (1) ))
>> (sort L)
>>
>
> Note that 'sort' is a destructive function, it modifies the order of cells
> in-place. Thus you must use the return value of 'sort', it may return another
> cell than was passed to it.
>
> In the above, the return value of 'sort' is ignored and thus lost.
>
> Try either
>
> : (length (sory L))
>
> or
>
> : (setq L (sort L))
>
> ☺/ A!ex
>
> -- 
> UNSUBSCRIBE: mailto:> picolisp@software-lab.de 
> <mailto:picolisp@software-lab.de>> ?subject=Unsubscribe
>


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


Re: ext:Snx undefnied pil32 termux local build

2019-04-20 Thread JmageK
Thanks for searching but it appears to be the same as what I did. Comment M32 
option.

JmageK
-- 
Securely sent with Tutanota



Apr 21, 2019, 1:03 AM by erik.d.gustaf...@gmail.com:

> This might work - Compile 32-bit picolisp on ARM (RPi)
>
> https://gist.github.com/aw/714d1840bbabb782ecb2 
> <https://gist.github.com/aw/714d1840bbabb782ecb2>
>
>
> /erik 
>
> On Sat, Apr 20, 2019, 9:14 AM JmageK <> jmagek@tutaio <mailto:jmagek@tutaio>> 
> > wrote:
>
>> Does anyone have a working makefile for pil32 arm? or can help me get this 
>> working.
>>  
>>  I compiled pil32 on termux with gcc-8, it works but fails the test for 
>> ext:Snx 'Common lisp' string, ext:Base64 does not work too. But (ht:Prin 
>> 212) and (ht:Pack '("h" "n")) work fine.
>>  The ext file is present in the lib/ folder same as ht.
>>  
>>  The few changes I did was comment the unrecognized m32 option and change 
>> the pil script to include the full path names to the binary and lib.l file.
>>  
>>  I had got this working months ago but unfortunatley do not remember what I 
>> did and neither have that modified Makefile.
>>  The dist package from 'itspointless' is outdated 18.x.x and fails some 
>> basic tests so can't use that too.
>>  
>>  
>>  JmageK
>>  -- 
>>  Securely sent with Tutanota
>>  
>>  -- 
>>  UNSUBSCRIBE: mailto:>> picolisp@software-lab.de 
>> <mailto:picolisp@software-lab.de>>> ?subject=Unsubscribe
>>


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


Re: ext:Snx undefnied pil32 termux local build

2019-04-20 Thread JmageK
I do have a seperate pil64 install for the emulated version. It's just that it 
can be slow, startup(in debug mode) and numeric computation.

When doing certain things the performance gap between pil32 and emu pil64 can 
also be quite high

$ pil64 
: (Bench(t (who 'car] 
-> 13.575 secs

$ pil
: (bench (t (who 'car]
-> 0.304 secs

 I didn't think of this before but now tried copying the picolisp binary and 
some of it's folders into the install directory. All tests pass so it's fine. 
Will reply to the original email should I find something next week or so.
Thanks for answering.

JmageK
-- 
Securely sent with Tutanota



Apr 20, 2019, 9:09 PM by a...@software-lab.de:

> Hi JmageK,
>
>> Does anyone have a working makefile for pil32 arm? or can help me get this
>> working.
>>
>
> I don't have a Makefile, and in fact nothing for pil32, but if pil64 and/or
> emu32 is OK for you, you can grab the scripts
>
> PilBox/mk.arm64.android
> PilBox/mk.emu.arm32
>
> from > https://software-lab.de/PilBox.tgz <https://software-lab.de/PilBoxtgz>
>
> The README in that the tarball (or at > https://software-lab.de/PilBox/README 
> <https://software-lab.de/PilBox/README>> )
> explains what you need to build from scratch in the chapter "Building the 
> PilBox
> Kernel".
>
>
> If you just want the latest binaries, you find the 64-bit versions
>
> PilBox/picoLisp/bin/picolisp
> PilBox/picoLisp/lib/ext
> PilBox/picoLisp/lib/ht
>
> in the tarball too. They run fine in Termux, they are what I use myself.
>
> The 32-bit emu versions are in > https://software-lab.de/emu32.zip 
> <https://software-lab.de/emu32.zip>
>
> ☺/ A!ex
>
> -- 
> UNSUBSCRIBE: mailto:> picolisp@software-lab.de 
> <mailto:picolisp@software-lab.de>> ?subject=Unsubscribe
>


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


ext:Snx undefnied pil32 termux local build

2019-04-20 Thread JmageK
Does anyone have a working makefile for pil32 arm? or can help me get this 
working.

I compiled pil32 on termux with gcc-8, it works but fails the test for ext:Snx 
'Common lisp' string, ext:Base64 does not work too. But (ht:Prin 212) and 
(ht:Pack '("h" "n")) work fine.
The ext file is present in the lib/ folder same as ht.

The few changes I did was comment the unrecognized m32 option and change the 
pil script to include the full path names to the binary and lib.l file.

I had got this working months ago but unfortunatley do not remember what I did 
and neither have that modified Makefile.
The dist package from 'itspointless' is outdated 18.x.x and fails some basic 
tests so can't use that too.


JmageK
-- 
Securely sent with Tutanota

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