Cool - I'll have a go.

Thanks,

Phil

Slava Pestov wrote:
> Hi Phil,
> 
> Factor has four types of homogeneous arrays:
> 
> - string
> - byte-array
> - bit-array
> - float-array
> 
> What you're proposing is subtly different -- a sequence backed by an 
> underlying alien object. That would be very valuable too, especially if 
> such sequence classes could be auto-generated for all C types one is 
> interested in (try doing it with parsing words!)
> 
> Have fun,
> 
> Slava
> 
> Phil Dawes wrote:
>> Hi Factor team,
>>
>> I've been using a ulong array type in my code for a while, and I noticed 
>> that Joel's code [1] would benefit from a float-array type.
>>
>> E.g.
>>
>> TUPLE: float-array address length ;
>>
>> C: <float-array> float-array
>>
>> M: float-array length float-array-length ;
>> M: float-array nth-unsafe float-array-address float-nth ;
>> M: float-array set-nth-unsafe float-array-address set-float-nth ;
>>
>> --------
>>
>> and maybe:
>>
>> : with-mapped-float-array ( fname quot -- )
>>    >r dup file-length r>
>>    [ [ mapped-file-address ] keep length 4 / <float-array>
>>    ] swap compose with-mapped-file ;
>>
>> --------
>>
>> ... could make the faster version of Joel's code much cleaner:
>>
>> : (sum-floats)
>>    0 [ clip + 2 / ] reduce ;
>>
>> : sum-floats
>>      "/tmp/floats.bin" [ (sum-floats) ] with-mapped-float-array ;
>>
>>
>> I get the same times using this as with the faster version in Joel's 
>> post. Do you think it's worthwhile me adding homogeneous arrays to the 
>> factor library?
>>
>> Cheers,
>>
>> Phil
>>
>> [1] http://www.wagerlabs.com/blog/2008/01/introducing-fac.html
>>
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Microsoft
>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> _______________________________________________
>> Factor-talk mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>>   
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
> 



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to