Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] printable digest strings
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Miles Egan <miles@c...>
Subject: Re: [Caml-list] printable digest strings
On Fri, May 04, 2001 at 11:37:27AM +0200, Xavier Leroy wrote:
> let string_map f s =            
>   let rec map_aux res idx =
>     if idx < 0 then res else map_aux (f s.[idx] :: res) (idx - 1)  
>   in map_aux [] (String.length s - 1)
> 
> let hexstring s =
>   String.concat "" 
>     (string_map (fun c -> Printf.sprintf "%02x" (Char.code c)) s)

I knew there had to be a better way.  Thanks.

This actually brings me to my next question.  There doesn't seem to be a
String.map or String.iter function in the standard library, although I can
imagine they might also be handy.  Am I looking in the wrong place?

-- 
miles
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr