PDA

View Full Version : Ocaml problem refering to Lists


Branco
11-03-2003, 06:29 PM
what i wanna know is how to refer to all the elements to a list in the next exampe:

let rec concat = function
[] -> []
|[n] -> n
|[f;<what ever it be>] -> f @ (concat <watever it be>);;

im tryingo to define List.concat like a function and have that problem, can anyone help me :(

phubuh
11-10-2003, 05:06 PM
I think the pattern matching construct you want to use is x :: xs, not [x; xs] -- the latter is a list of two elements, whereas the former is a list of one or more elements.

jemfinch
12-31-2003, 07:17 AM
And note that in O'Caml, they traditionally say "hd :: tl", not "x :: xs".

Jeremy