Re: Pseudo Random Number Generation across PicoLisp implementations

2015-04-27 Thread Alexander Burger
Hi Christophe,

> Would it be possible to just cast (Seed >>> 32) to a long:
> 
> if ((n = evInt(ex.Cdr) + 1 - ((Number)x).Cnt) != 0)
> n = (long)(Seed >>> 32) % n;

Yes, this seems to be a good idea.

The (long) cast should not be needed, as 'Seed' and 'n' already are long
numbers. So if I change this to

   n = (Seed >>> 32) % n;

should it be OK?


> Some naive tests (see here: http://pastebin.com/hnnRLPA0) seem
> to confort my idea, but I may have missed something (again).

Good. I have changed it, and uploaded a new version. Can you perhaps
test it a little more?

Thanks for the input!
♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: In ersatz, seed is not returning a "small" number

2015-04-27 Thread Alexander Burger
Hi Christophe,

> In seed, line 3310 of fun.src, I'd suggest a 32 bits shift then a cast
> to an int for the result to conform to the docs:
> http://www.software-lab.de/doc/refS.html#seed
> 
> n = (int)((initSeed(ex.Cdr.Car.eval()) * 6364136223846793005L) >>> 32);

Good, but this is not completely correct. It stores the reduced 32-bit
value in 'Seed'. I think 'Seed' must keep the full 64-bit value.

I changed it to

   return new Number((int)((Seed = initSeed(ex.Cdr.Car.eval()) * 
6364136223846793005L) >>> 32));

which is also more analog to pil32. What do you think?


It is also in the new release. Can you test a little more?

Again, thanks for the input!
♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


In ersatz, seed is not returning a "small" number

2015-04-27 Thread Christophe Gragnic
Dear list,

In seed, line 3310 of fun.src, I'd suggest a 32 bits shift then a cast
to an int for the result to conform to the docs:
http://www.software-lab.de/doc/refS.html#seed

n = (int)((initSeed(ex.Cdr.Car.eval()) * 6364136223846793005L) >>> 32);


chri

-- 

http://profgra.org/lycee/ (site pro)
http://delicious.com/profgraorg (liens, favoris)
https://twitter.com/profgraorg
http://microalg.info
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


unsubscribe

2015-04-27 Thread Will Arnold

Good bye Will Arnold  :-(
You are now unsubscribed



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


Re: Pseudo Random Number Generation across PicoLisp implementations

2015-04-27 Thread Christophe Gragnic
On Mon, Apr 27, 2015 at 8:01 AM, Alexander Burger  wrote:
> […]
> A shift of 32 bits, however, would not suffice, because
> it would put the sign bit of the original 64-bit number into the MSB of
> the result.

OK, I understand.

I have some more ideas to try to make the behaviors of
(rand m n) in pil32 and ersatz the same, but maybe you are
not so much interested. Let me try one.
Would it be possible to just cast (Seed >>> 32) to a long:

if ((n = evInt(ex.Cdr) + 1 - ((Number)x).Cnt) != 0)
n = (long)(Seed >>> 32) % n;
return new Number(((Number)x).Cnt + n);

Some naive tests (see here: http://pastebin.com/hnnRLPA0) seem
to confort my idea, but I may have missed something (again).

If still wrong, I may implement a smaller generator specially for my
language. Like one with just Xn+1 = a Xn, and
a(m−1)<2^53 (for ability to use withe JS numbers).
Inspired by Wikipedia and this paper:
http://www.ams.org/journals/mcom/1999-68-225/S0025-5718-99-00996-5/S0025-5718-99-00996-5.pdf
BTW, I wonder why MINSTD is not listed in Table 3.


chri

-- 

http://profgra.org/lycee/ (site pro)
http://delicious.com/profgraorg (liens, favoris)
https://twitter.com/profgraorg
http://microalg.info
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


subscribe

2015-04-27 Thread Will Arnold

Hello Will Arnold  :-)
You are now subscribed



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


Re: MySQL native C wrapper

2015-04-27 Thread Henrik Sarvell
Yes, you're right, I'll remove it and "link" straight to the lib, it
was something I did in the beginning of the process when I was unsure
of how transparently I could pass references to structs around.

As it turned out it's completely seamless so your suggestion makes
perfect sense, or be my guest and do it yourself if you're anxious, I
won't have time until next weekend, feel free to copy whatever you
like from me.

On Mon, Apr 27, 2015 at 3:28 AM, Alexander Williams
 wrote:
> Henrik this is great!!
>
> I've been looking for something like this but it was a little lower on my 
> priority list. Thank you!
>
> I find it interesting that you wrote some C to initiate the mysql connection 
> Would it be easier to do it in PicoLisp and simply use libmysqlclient.so ?
>
> On 2015-04-27, at 6:00 AM, Henrik Sarvell  wrote:
>
>> Hi list, I'm announcing this at a very early stage, earlier than I
>> would like to, in case someone else is also thinking about doing a
>> MySQL wrapper, to avoid duplicate work.
>>
>> I'm not doing this because I think that MySQL is in any way a better
>> alternative than the native DB functionality, rather the opposite.
>>
>> The main reasoning is that it might help adoption of the language as
>> I've come to believe that how the data is stored could be as big a
>> hurdle to switch as the language switch itself - for many
>> organisations - if they can keep their data as it is (to begin with)
>> half the battle might already be won.
>>
>> PicoLisp with MySQL is still better than say PHP with MySQL.
>>
>> It also helps in migrating from MySQL to the native DB.
>>
>> It's all inspired by Alex Williams' nice and instructive use of the
>> native stuff here: http://aw.github.io/picolisp//2015/02/22/nanomsg/
>>
>> And I couldn't have managed without AB's writeup here:
>> http://software-lab.de/doc/native.html
>>
>> Without further ado:
>> https://bitbucket.org/hsarvell/ext/src/default/mysql.l?at=default
>>
>> Note that you can't just run with the file linked to above, you need
>> the mysql.so file in the ext/so folder too.
>>
>> If no one beats me to it I will do some more work on this one in the
>> future and will announce here when there's something to show.
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe