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

2017-02-18 Thread Lindsay John Lawrence
Thanks Alex,

In the context of

: (glue " " (filter prog (split (chop "  s  pac e s") " ")))
-> "s pac e s"

where

: (split (chop "  s  pac e s") " ")
-> (NIL NIL ("s") NIL ("p" "a" "c") ("e") ("s"))

it is not immediately obvious to me that the arguments passed to the
(filter prog ..) are treated as they are.

I'll have to think about it some more... and write more picolisp! but I am
confident I will figure it out in time =)

/Lindsay


Update: 64-Bit PicoLisp in a Docker container

2017-02-18 Thread David Bloom
Hello List!

A user pointed out to me that (edit 'sym) didn't work in the TinyCore based
container.  vi was installed but getting it to work proved to be painful so
I set out to build a small, custom container using buildroot.  After much
doc reading I managed to build a 64-bit container with PicoLisp, vim, and
zsh installed all weighing in at only 30MB.

(edit 'sym) now works!  This is notably larger than the 14MB TinyCore image
and perhaps if I were to remove zsh it would get smaller but why not have
more tools in a still tiny image?  The real fun about having vi installed
in the container is that (edit ...) can be used for browsing databases too.

Please download, comment, and enjoy.  Thank you.

-David


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

2017-02-18 Thread Lindsay John Lawrence
Thanks Alex.

I was sure there was something like 'bool' to replace '((E) E)... I just
could not find it at the time. =)

I am surprised that 'prog works. Why, in this context, does it treat it's
argument as 'data'?

Given (NIL NIL NIL ("s" "p" "a" "a" "a" "c" "e" "s" ",") 

: (prog NIL)
-> NIL

: (prog ("s" "p" "a" "a" "a" "c" "e" "s" ","))
!? ("s" "p" "a" "a" "a" "c" "e" "s" ",")
"s" -- Undefined

? (prog '("s" "p" "a" "a" "a" "c" "e" "s" ","))
-> ("s" "p" "a" "a" "a" "c" "e" "s" ",")

/Lindsay


Re: Serial communication?

2017-02-18 Thread Alexander Burger
On Sat, Feb 18, 2017 at 09:24:09AM +0100, Alexander Burger wrote:
>(out "/dev/ttyACM0"
>... )
> 
>(in "/dev/ttyACM0"
>... )

Some devices don't like it very much to be opened and closed all the time
(losing queued data, for example). In that case, you could try:

   (let? Dev (open "/dev/ttyACM0")
  (loop
 (in Dev
... )
 ...
 (out Dev
... ) ) )

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


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  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: 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: Serial communication?

2017-02-18 Thread Alexander Burger
On Sat, Feb 18, 2017 at 09:24:09AM +0100, Alexander Burger wrote:
>(err "/dev/null"  # stty arguments depend on your situation
>   (call "stty" "/dev/ttyACM0" "raw" "-echo" "-echoe" "-echok") )

Sorry, forgot the "-F"

  (call "stty" "-F" "/dev/ttyACM0" "raw" "-echo" "-echoe" "-echok") )

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


Re: Serial communication?

2017-02-18 Thread Alexander Burger
On Fri, Feb 17, 2017 at 10:15:55PM -0900, Christopher Howard wrote:
> Hi list. As mentioned before, I've got picolisp running on a mips32r2
> system running librecmc-1.3.4. I want to communicate with an ACM device
> available at /dev/ttyACM0. Is there a library for serial communication?
> And/Or do I need to interface to a C library?

I think it should be possible to directly read/write the device, perhaps after
calling 'stty' to set parameters

   (err "/dev/null"  # stty arguments depend on your situation
  (call "stty" "/dev/ttyACM0" "raw" "-echo" "-echoe" "-echok") )

Then

   (out "/dev/ttyACM0"
   ... )

   (in "/dev/ttyACM0"
   ... )

Use 'char' or 'line' to read text, or 'rd' to read binary data, and 'prin' or
'prinl' to write text, or 'wr' to write bytes.

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


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

2017-02-18 Thread Alexander Burger
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