estoy tratando de aprender ocaml en este momento y quería comenzar con un pequeño programa, generando todas las combinaciones de bits: ["0", "0", "0"] ["0", " 0" , "1"] [ "0", "1", "0"] ... y así sucesivamenteOcaml introducción
Mi idea es la siguiente código:
let rec bitstr length list =
if length = 0 then
list
else begin
bitstr (length-1)("0"::list);
bitstr (length-1)("1"::list);
end;;
pero me da la siguiente error:
Warning S: this expression should have type unit.
val bitstr : int -> string list -> string list = <fun>
# bitstr 3 [];;
- : string list = ["1"; "1"; "1"]
No entendí qué cambiar, ¿me puedes ayudar?
Saludos Philipp
ahh veo, gracias por la explicación! ¡Realmente me ayudaste! –