Loading...

factor-talk@lists.sourceforge.net

[Prev] Thread [Next]  |  [Prev] Date [Next]

[Factor-talk] Functional mandel Eduardo Cavazos Thu Sep 11 06:02:26 2008

Slava,

I messed around with a "functional" version of mandel. In this 
version 'mandel' is:

        : mandel ( -- data ) ppm-header render append ;

I.e. 'ppm-header' and 'render' return byte arrays which are then appended.

The current 'render' is:

: render ( -- )
    height [ width swap '[ _ c pixel color % ] each ] each ; inline

To get the functional version, throw out the '%' and convert the calls 
to 'each' with 'map concat':

: render ( -- data )
  height [ width swap '[ _ c pixel color ] map concat ] map concat ; inline

Taking the 'ppm-header' from my previous note and converting it:

: ppm-header ( -- data )
  width number>string height number>string
  -> WIDTH HEIGHT
    { "P6\n" WIDTH " " HEIGHT "\n255\n" }
  concat >byte-array ; inline

Of course this version of mandel is slower than the versions where a byte 
vector is appended to. Is there a chance that a functional version along 
these lines might someday be just as fast?

Ed

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/factor-talk