Re: Less powerful 'str?

2017-06-17 Thread Christopher Howard
I think I found what I was looking for, modifying an example from the docs:

: (mapcar pack (split (chop (line T)) " "))
go north
-> ("go" "north")

On 06/17/2017 02:35 PM, Joh-Tob Schäg wrote:
> Take a look at 'read.
> You may need to 'eval the result.
> If 'read does not suit your needs i wrote a tokenizer and parser but the
> source code is not yet ready fot publication
> 
> Am 17.06.2017 23:42 schrieb "Christopher Howard"
> >:
> 
> Hi list. I find that the 'str function is rather convenient for
> processing commands from the user, as it converts the input to list
> format, like in
> 
> : (str (line T))
> go north
> -> (go north)
> 
> However, it creates complications in allowing commands like:
> 
> : (str (line T))
> `(+ 1 2 3)
> -> (6)
> 
> and
> 
> : (str (line T))
> "crash!
> EOF Overrun
> ?
> 
> Is there another simple way to get the lists provided by 'str without
> the user this power to run code?
> 
> --
> https://qlfiles.net
> 
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de
> ?subject=Unsubscribe
> 

-- 
https://qlfiles.net

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


Re: Less powerful 'str?

2017-06-17 Thread Joh-Tob Schäg
Take a look at 'read.
You may need to 'eval the result.
If 'read does not suit your needs i wrote a tokenizer and parser but the
source code is not yet ready fot publication
Am 17.06.2017 23:42 schrieb "Christopher Howard" <
christopher.how...@qlfiles.net>:

> Hi list. I find that the 'str function is rather convenient for
> processing commands from the user, as it converts the input to list
> format, like in
>
> : (str (line T))
> go north
> -> (go north)
>
> However, it creates complications in allowing commands like:
>
> : (str (line T))
> `(+ 1 2 3)
> -> (6)
>
> and
>
> : (str (line T))
> "crash!
> EOF Overrun
> ?
>
> Is there another simple way to get the lists provided by 'str without
> the user this power to run code?
>
> --
> https://qlfiles.net
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Less powerful 'str?

2017-06-17 Thread Christopher Howard
Hi list. I find that the 'str function is rather convenient for
processing commands from the user, as it converts the input to list
format, like in

: (str (line T))
go north
-> (go north)

However, it creates complications in allowing commands like:

: (str (line T))
`(+ 1 2 3)
-> (6)

and

: (str (line T))
"crash!
EOF Overrun
?

Is there another simple way to get the lists provided by 'str without
the user this power to run code?

-- 
https://qlfiles.net

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


Re: single letters

2017-06-17 Thread George Orais
Hi Alex,

> Yes, 'low?' and "upp?" are a good idea. They do however return true also for 
> letters like "ä" / "Ä", so it depends on what the exact task is

Re: single letters

2017-06-17 Thread Alexander Burger
Hi Geo,

On Sat, Jun 17, 2017 at 06:07:16AM +, George Orais wrote:
> (de singleLetter? (item)   (and (=1 (length item)) (or (low? item) (upp? 
> item

Yes, 'low?' and "upp?" are a good idea. They do however return true also for
letters like "ä" / "Ä", so it depends on what the exact task is.

♪♫ Alex

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


Re: single letters

2017-06-17 Thread George Orais
(Resend to change to plain text format)


Hi, 

How about this: 

(de singleLetter? (item) 
   (if (and (=1 (length item)) (or (low? item) (upp? item))) 
   1 
   NIL)) 

This returns 1 if true then NIL for false. 



But if you just need NIL for false and then the letter itself for true, then 
can be shorten into this: 

(de singleLetter? (item) 
   (and (=1 (length item)) (or (low? item) (upp? item 



BR, 
geo 

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


Re: single letters

2017-06-17 Thread George Orais
Hi,
How about this:
(de singleLetter? (item)   (if (and (=1 (length item)) (or (low? item) (upp? 
item))) 1 NIL))
This returns 1 if true then NIL for false.


But if you just need NIL for false and then the letter itself for true, then 
can be shorten into this:
(de singleLetter? (item)   (and (=1 (length item)) (or (low? item) (upp? 
item


BR,geo



 

On Saturday, June 17, 2017 2:52 PM, Alexander Burger  
wrote:
 

 On Sat, Jun 17, 2017 at 07:35:44AM +0200, Alexander Burger wrote:
> On Fri, Jun 16, 2017 at 06:31:06PM -0800, Christopher Howard wrote:
> > Hi list. In picolisp, what would be the simplest way to check if a
> > string (trans sym) is one character long and that the character is one
> > of the letters a-z or A-Z?
> 
> I would do:
> 
>    (member C '`(mapcar char (conc (range 65 90) (range 97 122

Sorry, no!

It is shorter, faster and more readable to do:

  (or (>= "Z" C "A") (>= "z" C "a"))

♪♫ Alex

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