hi,
someone could help me?
i have this error " Error: This expression has type string list
but an expression was expected of type char list list
Type string is not compatible with type char list "
hi,
someone could help me?
i have this error " Error: This expression has type string list
but an expression was expected of type char list list
Type string is not compatible with type char list "
you should post more details if you want some help!
your error message is quite clear: you are using a function that requires a char list, something like ['a'; 'b'; 'c']
, but instead you are giving this function a string, like "abc"
.
i did that
let rec listes_paires l =
match l with
| →
| fst :: rest → if length fst mod 2 = 0 then (fst :: (listes_paires rest))
else ((fst@fst):: (listes_paires rest));;
let l2 = [; [1];[1;2];[1;2;3];;[5;4;3;2;1]];;
let l3 = [;[“titi”]; [“titi”;“toto”]];;
let () = Format.printf “%a\n@?” pr_lchar (listes_paires l3);;
let () = Format.printf “%a\n@?” pr_lint (listes_paires l2);;
Can you format your code using the markup mentioned in a previous thread? It’s difficult to read as is.
like that ‘’'let rec listes_paires l =
match l with
| →
| fst :: rest → if length fst mod 2 = 0 then (fst :: (listes_paires rest))
else ((fst@fst):: (listes_paires rest));;
let l2 = [; [1];[1;2];[1;2;3];;[5;4;3;2;1]];;
let l3 = [;[“titi”]; [“titi”;“toto”]];;
let () = Format.printf “%a\n@?” pr_lchar (listes_paires l3);;
let () = Format.printf “%a\n@?” pr_lint (listes_paires l2);;‘’’
Use the “preformatted text” icon </>
in the message editor
or manually:
```ocaml
type your code here
```