Serial communication?

2017-02-17 Thread Christopher Howard
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?

-- 
https://qlfiles.net
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


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

2017-02-17 Thread Lindsay John Lawrence
(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 space??

2017-02-17 Thread Joe Bogner
fun

does this do it?

(pack (mapcon '((X) (ifn (= '(" " " ") (head 2 X)) (cons (car X (chop
S)))
-> " this contains 2 consecutive spaces "


On Feb 17, 2017 5:23 PM, "dean"  wrote:

> 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: (= code data)

2017-02-17 Thread Rowan Thorpe
On 6 February 2017 at 20:03, Danilo Kordic  wrote:
> ..[snip]..
>
> Hi Rowan.
>
> [de help: [Sym Txt]
>   [def Sym 'help: Txt] ]
>
> [help: "`prop'erty is clearly better than a txt in `prg' if it should
> be extracted by a procedure.  "
>   [de help [Sym]
> "I prefer even this over Reader Comments (``#'').  "
> [get Sym 'help:] ] ]

Thanks for that, Danilo. I was a bit confused for a while though
because (I think?) there is a typo in it - it doesn't work for me
as-is. Anyway, your pointing out the use of a property on the function
made sense. I managed to get a version of it working which I like (see
below), particularly because it makes passing in "lambdas" trivial as
a single arg, and is easy to visually parse with that in mind). I
guess the main benefit of using the property-approach is that it won't
have any speed impact on the function when it runs, whereas including
a "docstring" like I was doing will cause the string to be silently
"evaluated" every time the function is run... Just out of curiosity,
is that the main/only reason? or are there other reasons I haven't
thought of? BTW: The version I came up with is:

8<

(de hde (Sym Txt Fn)
   (def Sym Fn)
   (def Sym 'help: Txt) )
-> hde

(hde 'help "This is the help function"
   '((X) (get X 'help:)) )
-> help

(hde 'tester "This is the tester function"
   '((X) (println X)) )
-> tester

(help 'tester)
-> "This is the tester function"

(tester 123)
123
-> 123

8<

-- 
Rowan Thorpe

"A riot is the language of the unheard." - Dr. Martin Luther King
"There is a great difference between worry and concern. A
worried person sees a problem, and a concerned person solves a
problem." - Harold Stephens
"Ignorance requires no apologies when it presents questions
rather than assertions." - Michael Sierchio (OpenSSL mailing list)
"What we need more than an end to wars is an end to the
beginning of all wars." - Franklin Roosevelt
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


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'


REPL in the browser, picolisp as primary example/screenshot

2017-02-17 Thread Rowan Thorpe
I wrote a little proof-of-concept tool to embed an arbitrary REPL in
the browser using websocketd in the backend - nothing particularly
clever or high-profile about that, I know - but more relevant here is
that I used picolisp (pil) as first example, and in the first
screenshot :-)

  https://github.com/rowanthorpe/ws-repl

The websocketd project links to it as an example project too, so
hopefully some of the Go fans browsing there will end up discovering
picolisp that way...

  https://github.com/joewalnes/websocketd#user-content-example-projects

BTW: Maybe a heavily sandboxed, rate-limited picolisp with a strict
reset-timeout could be included this way in a "Try it online here!"
section on the picolisp.com homepage? If the site is hosted on
standard web-hosting rather than a VPS then the websocket process
would require hosting separately with cross-site protection and/or
firewalling of its port, though. Then again, due to extra load on the
server and potential security holes (extra maintenance burden) it may
not be worth it at all. Anyway, just an idea...

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