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 ocaml.org.

Browse thread
string -> charlist
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-05-08 (11:55)
From: Oliver Bandel <oliver@f...>
Subject: string -> charlist
Hello,

I got a problem, that only occurs in compilation and not
in the toplevel (but the toplevel prints warnings about
the type (should be unit)).

Here is the problematic code:


####################################################

let rec charlist_of_string str =
let len = String.length str in
if len = 0 then []
else
str.[0] :: charlist_of_string (String.sub str 1 (len -1))



charlist_of_string "Hallo9z g g"

####################################################

In the toplevel I got the result: a list of char's.
But compiling with ocamlc or ocamlopt says that
the types in the application of the function are not
matching.

What is the problem here?


TIA,
Oliver