So I am trying to code a relatively simple function in OCaml which takes an integer n and a list of integers up to 5 and then repeats all integers above 1 in said list n times.
I already have an existing function repeat which repeats whatever I feed it n times
let rec repeat : int -> 'a -> 'a list =
fun n a ->
match n with
| 0 -> []
| h -> a :: repeat (h-1) a ;;
Now here is the code for the function called Pentograph
let pentograph : int -> int list-> int list =
fun n letter ->
match letter with
|[] -> []
|h::t -> if h>1 then List.concat[(repeat n h);pentograph n t] else List.conca[h;pentograph n t];;
I get the following error:
Error: Unbound value pentograph
On trying to use the :: operator I get an error too as I can not use it to concat 2 lists.
Please help me figure out a solution to this problem!