Copying Lists 
Author Message
 Copying Lists

Quote:
> testbit in a rather peculiar fashion.

>      bool -> testbit( NUMBER, BITNUM ) -> NEW_NUMBER

> Using this, your mutate routine would go from this ...

> >define mutate(chom);
> >lvars pos;
> >     1 + random0( chom_length) -> pos;

> >     if population(chom)(pos) == 1 then
> >         0 -> population(chom)(pos);
> >     else
> >         1 -> population(chom)(pos);
> >     endif;
> >enddefine;

> ... to this ...

> define mutate( chom );
>      lvars pos = random( chom_length );   ;;; random = random0 + 1
>      ;;; toggle the pos'th bit.
>      not( testbit( population( chom ), pos ) ) -> testbit(
> population(
> chom ), pos )
> enddefine;

Is that right? It doesn't look like you've updated chom with the new
number...

Shouldn't it be:

define mutate( chom );
     lvars pos = random( chom_length );   ;;; random = random0 + 1
     lvars bitvec = population(chom);
     ;;; toggle the pos'th bit.
     not(testbit(bitvec, pos )) -> testbit(bitvec, pos) ->
population(chom);
enddefine;

[and other judicious use of fast_subscrv to speed things up of course
;-]

Ian
--
www.ianrogers.net



Mon, 18 Apr 2005 02:06:52 GMT  
 Copying Lists
Hi Ian,

Quote:
>  > define mutate( chom );
>>       lvars pos = random( chom_length );   ;;; random = random0 + 1
>>       ;;; toggle the pos'th bit.
>>       not( testbit( population( chom ), pos ) ) -> testbit(
>>  population(
>>  chom ), pos )
>>  enddefine;

>Is that right? It doesn't look like you've updated chom with the new
>number...

>Shouldn't it be:

>define mutate( chom );
>      lvars pos = random( chom_length );   ;;; random = random0 + 1
>      lvars bitvec = population(chom);
>      ;;; toggle the pos'th bit.
>      not(testbit(bitvec, pos )) -> testbit(bitvec, pos) ->
>population(chom);
>enddefine;

Ah, poo.  You're right of course.  That's what happens when you don't
have a version of Poplog on the same system as you do email.

--
Steve



Mon, 18 Apr 2005 10:22:33 GMT  
 Copying Lists

Quote:
>Ah, poo.  You're right of course.  That's what happens when you don't
>have a version of Poplog on the same system as you do email.

BTDT ;-).

--
Jonathan Cunningham
[backlog back above 1000]



Mon, 18 Apr 2005 18:56:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Copying Lists

2. How to copy lists and dictionaries?

3. copy list, which way is best? /style

4. Copying Lists

5. Please help with copy-list.

6. Please help with copy-list.

7. ASCII copy of Error List in App Gen?

8. problem copying posts to list-server?

9. A hack for "list-copy"

10. I got my copy of the November compiler list

11. Initializing a list with copies

12. Problems with copies (and references) to lists

 

 
Powered by phpBB® Forum Software