[REBOL] Re: Temporal data [was is REBOL OO]
From: g:santilli:tiscalinet:it at: 14-Jan-2004 14:09
Hi SunandaDH,
On Wednesday, January 14, 2004, 11:15:52 AM, you wrote:
Sac> What we need is the location of the first occurrence of n consecutive 1-bits:
Sac> available? bit-map 5
Sac> available? bit-map 12
Sac> Puzzle 2:
Sac> 256 bits isn't enough for a bit-per-day for a whole year. We need two
Sac> bitmaps.
Sac> Extend available? to find n consecutive bits within a bitset, or across a
Sac> bitset boundaries:
Well, since we're talking 356 bits, maybe you'll forgive me
wasting some memory.
>> bitmap: "000110101000111111100101001111111" ;... till 356 days
== "000110101000111111100101001111111"
>> available?: func [bitmap cons] [if bitmap: find bitmap head insert/dup clear "" 1
cons [index? bitmap]]
>> available? bitmap 1
== 4
>> available? bitmap 2
== 4
>> available? bitmap 3
== 13
>> available? bitmap 5
== 13
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/