Suppose you have a length-n array x of Uint8's = [1,5,32,7,...] , and you want to convert this to a long string of hex digits (two per x[i]). The code y = reduce(string, [hex(xi,2) for xi in x]) ==> "01052007..." will do the trick. (Or, you could use map_reduce or one of the fold operations.)
But I would like this operation to run in linear time. Would any of the reduce, map_reduce, or fold operations run in linear time? With a strict abstract implementation, each intermediate result string would need to be created, and each such intermediate result string is immutable, so the running time would be Theta(n^2). Or is the compiler smart about this case? (A small experiment suggests not.) Perhaps the right approach is: x2 = [ hex(xi,2) for xi in x] y = string(x2) ?? Cheers, Ron