Re: help extracting number from string

2016-12-15 Thread Joe Bogner
This is probably better:

: (extract format (split (mapcar format (chop "35fabc79")) NIL))
-> (35 79)



On Thu, Dec 15, 2016 at 7:57 PM, Joe Bogner  wrote:

> OK, how about this this?
>
> : (mapcar format (extract pack (split (mapcar format (chop "35fabc79"))
> NIL)))
> -> (35 79)
>
> : (mapcar format (extract pack (split (mapcar format (chop "35f79")) NIL)))
> -> (35 79)
>
> On Thu, Dec 15, 2016 at 7:36 PM, Joh-Tob Schäg 
> wrote:
>
>> If i understood it correctly he wants to get all groups of number.
>> "35f79" -> (35  79)
>> Am 16.12.2016 09:28 schrieb "Joe Bogner" :
>>
>>> how about
>>>
>>> : (extract format (chop 'ab33Cd))
>>> -> (3 3)
>>>
>>> or
>>>
>>> : (format (pack (extract format (chop 'ab33Cd
>>> -> 33
>>>
>>>
>>> On Thu, Dec 15, 2016 at 4:16 PM, dean  wrote:
>>>
 I've seen num? and chop but think I need something in the middle to
 turn a character to a number

 Having said that I seem to have got close by accident...i.e. I was
 going to try and bend this...but it found a single integer as it was :)

 : (pick '((Ch) (and (= Ch (uppc Ch)) Ch)) (chop 'ab33Cd))
 -> "3"

 I'd like this to detect 33 but see that chop precludes this.

 Any help much appreciated.


>>>
>


Re: help extracting number from string

2016-12-15 Thread Joe Bogner
OK, how about this this?

: (mapcar format (extract pack (split (mapcar format (chop "35fabc79"))
NIL)))
-> (35 79)

: (mapcar format (extract pack (split (mapcar format (chop "35f79")) NIL)))
-> (35 79)

On Thu, Dec 15, 2016 at 7:36 PM, Joh-Tob Schäg  wrote:

> If i understood it correctly he wants to get all groups of number. "35f79"
> -> (35  79)
> Am 16.12.2016 09:28 schrieb "Joe Bogner" :
>
>> how about
>>
>> : (extract format (chop 'ab33Cd))
>> -> (3 3)
>>
>> or
>>
>> : (format (pack (extract format (chop 'ab33Cd
>> -> 33
>>
>>
>> On Thu, Dec 15, 2016 at 4:16 PM, dean  wrote:
>>
>>> I've seen num? and chop but think I need something in the middle to turn
>>> a character to a number
>>>
>>> Having said that I seem to have got close by accident...i.e. I was going
>>> to try and bend this...but it found a single integer as it was :)
>>>
>>> : (pick '((Ch) (and (= Ch (uppc Ch)) Ch)) (chop 'ab33Cd))
>>> -> "3"
>>>
>>> I'd like this to detect 33 but see that chop precludes this.
>>>
>>> Any help much appreciated.
>>>
>>>
>>


Re: help extracting number from string

2016-12-15 Thread Joh-Tob Schäg
If i understood it correctly he wants to get all groups of number. "35f79"
-> (35  79)
Am 16.12.2016 09:28 schrieb "Joe Bogner" :

> how about
>
> : (extract format (chop 'ab33Cd))
> -> (3 3)
>
> or
>
> : (format (pack (extract format (chop 'ab33Cd
> -> 33
>
>
> On Thu, Dec 15, 2016 at 4:16 PM, dean  wrote:
>
>> I've seen num? and chop but think I need something in the middle to turn
>> a character to a number
>>
>> Having said that I seem to have got close by accident...i.e. I was going
>> to try and bend this...but it found a single integer as it was :)
>>
>> : (pick '((Ch) (and (= Ch (uppc Ch)) Ch)) (chop 'ab33Cd))
>> -> "3"
>>
>> I'd like this to detect 33 but see that chop precludes this.
>>
>> Any help much appreciated.
>>
>>
>


Re: help extracting number from string

2016-12-15 Thread Joe Bogner
how about

: (extract format (chop 'ab33Cd))
-> (3 3)

or

: (format (pack (extract format (chop 'ab33Cd
-> 33


On Thu, Dec 15, 2016 at 4:16 PM, dean  wrote:

> I've seen num? and chop but think I need something in the middle to turn a
> character to a number.
>
> Having said that I seem to have got close by accident...i.e. I was going
> to try and bend this...but it found a single integer as it was :)
>
> : (pick '((Ch) (and (= Ch (uppc Ch)) Ch)) (chop 'ab33Cd))
> -> "3"
>
> I'd like this to detect 33 but see that chop precludes this.
>
> Any help much appreciated.
>
>


Re: help extracting number from string

2016-12-15 Thread Joh-Tob Schäg
I am just telling you pick can not help you here.
In this case just write a coroutine. You can handle different reading modes
(numbers vs strings) in there easily.
Am 16.12.2016 06:24 schrieb "dean" :

> I've seen num? and chop but think I need something in the middle to turn a
> character to a number.
>
> Having said that I seem to have got close by accident...i.e. I was going
> to try and bend this...but it found a single integer as it was :)
>
> : (pick '((Ch) (and (= Ch (uppc Ch)) Ch)) (chop 'ab33Cd))
> -> "3"
>
> I'd like this to detect 33 but see that chop precludes this.
>
> Any help much appreciated.
>
>


Re: Discrepancies in lib/misc.l between picoLisp and miniPicoLisp

2016-12-15 Thread Christophe Gragnic
On Thu, Dec 15, 2016 at 2:22 PM, Alexander Burger  wrote:
> Hi Christophe,
>
>> Trying to port tests to miniPicoLisp I needed to copy some
>> definitions from lib/misc.l from pico to mini, and this is what I found:
>>
>> 1) Many definitions don't appear in pico. Is it intented ? If so, why ?
>
> Don't appear in *mini*, you mean?

Yes sorry.

> Well, yes, it is "mini" after all ;)

And I plan to make an even smaller version!

>> Just to mention my findings. It may be intented for the sake of
>> simplicity of mini.
>
> Thanks! I put 'format' in mini into my todo list :)

Glad to see you are interested.
Two others, but I understand that mini could have severe limitations that
would prevent a fix:
1) «seed» only accepts numbers in mini,
2) «in» doesn't support negative numbers in mini.

I'll keep you updated if I find some more.


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


help extracting number from string

2016-12-15 Thread dean
I've seen num? and chop but think I need something in the middle to turn a
character to a number.

Having said that I seem to have got close by accident...i.e. I was going to
try and bend this...but it found a single integer as it was :)

: (pick '((Ch) (and (= Ch (uppc Ch)) Ch)) (chop 'ab33Cd))
-> "3"

I'd like this to detect 33 but see that chop precludes this.

Any help much appreciated.


Re: Loosing elements in a sorted list

2016-12-15 Thread Alexander Burger
Hi Bruno,

> But that might be because with 'by, the operation is not destructive.

This is correct. 'sort' is destructive, and 'by' is not, because it builds a
fresh, private list.


> Is this normal operation of picolisp? I assumed its not, because I didn't
> catch any reference to it in the documentation.

Every destructive function should be marked as such in the reference. Let us
know when you find a case where this is missing.

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


Re: Discrepancies in lib/misc.l between picoLisp and miniPicoLisp

2016-12-15 Thread Alexander Burger
Hi Christophe,

> Trying to port tests to miniPicoLisp I needed to copy some
> definitions from lib/misc.l from pico to mini, and this is what I found:
> 
> 1) Many definitions don't appear in pico. Is it intented ? If so, why ?

Don't appear in *mini*, you mean? Well, yes, it is "mini" after all ;) And many
features of real PicoLisp will not work anyway.


> 2) Discrepancy in the $dat implementation:
> 
> mini
> (format (pack (car S)))# Year
> (or (format (pack (cadr S))) 0)# Month
> (or (format (pack (caddr S))) 0) ) )   # Day
> 
> pico
> (format (car S))   # Year
> (or (format (cadr S)) 0)   # Month
> (or (format (caddr S)) 0) ) )  # Day

Yes, 'format' was changed with picoLisp-3.0.3 in 2010 to accept also lists of
characters. Probably I forgot (or had problems?) to port this change to mini. So
the 'pack' is not necessary in PicoLisp any more, but still in miniPicoLisp.


> Just to mention my findings. It may be intented for the sake of
> simplicity of mini.

Thanks! I put 'format' in mini into my todo list :)

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


Discrepancies in lib/misc.l between picoLisp and miniPicoLisp

2016-12-15 Thread Christophe Gragnic
Hi,

Trying to port tests to miniPicoLisp I needed to copy some
definitions from lib/misc.l from pico to mini, and this is what I found:

1) Many definitions don't appear in pico. Is it intented ? If so, why ?

2) Discrepancy in the $dat implementation:

mini
(format (pack (car S)))# Year
(or (format (pack (cadr S))) 0)# Month
(or (format (pack (caddr S))) 0) ) )   # Day

pico
(format (car S))   # Year
(or (format (cadr S)) 0)   # Month
(or (format (caddr S)) 0) ) )  # Day

Tests of $dat written for picoLisp don't pass without the pack in miniPicoLisp.
That's because the format function in mini doesn't accept lists.
Just to mention my findings. It may be intented for the sake of
simplicity of mini.


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


Re: Loosing elements in a sorted list

2016-12-15 Thread Alexander Burger
On Wed, Dec 14, 2016 at 10:01:27PM -0500, John Duncan wrote:
> This is because A still points at the cons that was the head of the list
> before sorting. If you want to update it, you have to set A to the result
> of sort.

Yes. The point is that 'sort' is a "destructive" operation. See the reference of
'sort'.

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