[plt-scheme] Re: Using PLT Scheme libs elsewhere?
Thanks. I'd use UNLESS instead of (if (not blah) one-armed-if).
On May 18, 2007, at 4:18 AM, Jens Axel Søgaard wrote:
> Hi,
>
> SpinyNorman wrote:
>
>> Share? I'm flattered. Here it is, and my only claim at this
>> point is
>> that hey, it works. Algorithmic insights are more than welcome.
>>
>> (require (lib "md5.ss"))
>>
> This md5.ss implements MD5 in Scheme. The Java MD5 is probably
> implemented in C.
> So if you switch to a C-based MD5 implementation, you'll get a
> speedup. Here is
> what to do:
>
> (require (planet "digest.ss" ("soegaard" "digest.plt" 1 2)))
> (require mzscheme)
>
> (define test-string (make-string 10000))
>
> (define (md-file-chunks port chunk-size)
> (let loop ()
> (begin
> (display (md5 (read-bytes chunk-size port)))
> (newline))
> (if (not (eof-object? (peek-byte port)))
> (loop))))
>
> (md-file-chunks (open-input-string test-string) 1024)
>
> See
> <http://planet.plt-scheme.org/display.ss?
> package=digest.plt&owner=soegaard>
> for documentation.
>
> This was tested on Windows, but ought to work elsewhere too.
> You'll need a relatively new version of PLT Scheme, for
> example 369.100.
>
> It wasn't obvious whether you put the md-file-chunks in a module or
> whether you are using the top-level. If you are using the top-level,
> the line
>
> (require mzscheme)
>
> makes sure primitive operations are inlined.
>
> I'd love to hear your new timings.
>
> PS: Remember to close file ports after use.
>
> --
> Jens Axel Søgaard
>
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme