Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Fwd: Re: [Caml-list] The boon of static type checking
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-02-15 (01:17)
From: Aaron Bohannon <bohannon@c...>
Subject: Re: [Caml-list] String to list to string
Sorry to revive an old thread, but I have to add my $.02 here.

Jon Harrop wrote:
> Outrageously, the core library fails to provide an arbitrary number of 
> arbitrary functions. This exact question came up recently. The answer was 
> essentially: Why string -> char list and not string -> char array? Why string 
> -> char list and not string -> string list? And so on.

Instead of adding one of these functions, I would much rather see a 
"fold" function on strings in the String module.  The Array module has 
both "iter" and "fold" functions.  Why, then, would the String module 
provide an "iter" but no "fold"--in a functional language??  The 
addition of a fold function would very often eliminate the need to 
convert a string to a char list or to introduce imperative-style 
programming into an otherwise purely functional section of code (not to 
mention that writing "char_list_of_string" would become trivial if it 
ever were necessary to do so).

I acknowledge the fact that I can write my own fold function, but I just 
wanted to point out that this seems to be the most logical addition to 
the String module.


Aaron Bohannon