As it turns out, this is a perfect application for my persistent vectors library. I used the following test harness, matching your examples and using the more “elegant” style of tackling the problem using for loops. I think the performance speaks for itself.
#lang racket/base (require alexis/collection alexis/pvector) (define (map-once f ls) (extend (pvector) (for/sequence ([i (in-naturals)] [elm (in ls)]) (set-nth ls i (f elm))))) (define (sqr x) (* x x)) (define num-test-cases 10000) (define num-runs-per-f 3) (define v (extend (pvector) (take num-test-cases (randoms)))) (displayln "pvector method:") (for ([__ (in-range num-runs-per-f)]) (time (void (map-once sqr v)))) ; OUTPUT ; ---------------------------------------- ; pvector method: ; cpu time: 228 real time: 227 gc time: 64 ; cpu time: 163 real time: 163 gc time: 71 ; cpu time: 122 real time: 121 gc time: 31 Alexis -- 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.