Hi everyone!

I was asked to port my srfi-171 (transducers) to racket by a staggering number 
of people (3!!), so by extremely popular demand (by my standards) I have done 
so: https://git.sr.ht/~bjoli/racket-srfi-171-transducers

These transducers are more or less the same as the ones in clojure, so they 
have very little overhead (each transduction step is just a procedure call) and 
work eagerly. They currently use mutable hidden state (like the clojure 
transducers) for the stateful transducers, but someone clever could probably 
make the state at least visible without too much performance impact. The 
simplest way would be visible mutable state, which I had working for 
guile-scheme but chose not to use because it became very slow in some schemes.

The documentation in the SRFI document still holds with some small caveats: 
bytevector-u8-reduce/transduce is now bytes-transduce/reduce and 
tdelete-duplicates now takes three symbols 'eq?, 'eqv? or 'equal? instead of 
arbitrary equality predicates.

I have really no idea how to package things for racket, nor do I have much 
interest in doing so. I have played with it a bit, it seems to work. There is a 
small test-suite still written in guile scheme, which should be trivial to 
port. If someone wants to package this as a proper racket package, I would be 
happy to accept pull requests or even transfer the repository to someone else. 
The license used is sub-licenseable, so feel free. If I find the repo to my 
liking I will deprecate my port and link to you. 

Ideas for changes I would have done if I was using racket more than I actually 
do: a (transduce ...)-form that uses rackets sequence interface. Package it so 
It could be installed using raco. Port the test-suite. Another part is figuring 
out what to call the library. 

The SRFI-document can be found here: 
https://srfi.schemers.org/srfi-171/srfi-171.html

The rebellion transducers seem to be aimed at another use-case (streaming data, 
and parallelism) with other kind of guarrantees. It has a _significantly_ 
higher overhead. I tried the following in rebellion

#lang racket
(require rebellion/streaming/transducer)
(require rebellion/collection/list)

(define lst (build-list 100000 values))

(time (length (transduce (in-list lst)
                         (filtering odd?)
                         (mapping (lambda (x) (* x x)))
                         #:into into-list)))

and it takes about 5 seconds. The same thing using srfi-171 styled transducers 
takes about 3ms (if my head is with me this morning, that is about 1650x). I 
suspect I might be doing something wrong, or that there might be some quadratic 
behaviour somewhere.

Anyway, go forth and have some fun!

Best regards
Linus Björnstam
 - Just a lowly classical musician programming for fun

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/1154d9aa-de51-4292-9a08-b2e8f3150ca2%40www.fastmail.com.

Reply via email to