Hi,

Probably due to all operations not being in-place, chaining operations on 
bignums is very costful. 

for example, using bitwise-bit-field[1] on bignums is atrocious.

I also tried

  (define (reverse-bits n)
    (for/fold ([reversed 0])
              ([i (in-range (integer-length n))])
      (bitwise-ior (bitwise-arithmetic-shift-left reversed 1)
                   (or (and (bitwise-bit-set? n i) 1) 0))))

but it's not much better. Having in-place operations would help

  (define (reverse-bits n)
    (for/fold ([reversed 0])
              ([i (in-range (integer-length n))])
      (bitwise-arithmetic-shift-left! reversed 1)
      (bitwise-ior! reversed (or (and (bitwise-bit-set? n i) 1) 0))))

What do you think?

[1] 
https://github.com/racket/r6rs/blob/master/r6rs-lib/rnrs/arithmetic/bitwise-6.rkt#L89

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to