I am having hard time understanding ti let ..... in expression

I am new to ocaml and i am having trouble with i fuction that i am writing
I have to write a fuction that takes a list and returns a list of pairs of 1st and last element 2nd and 2nd last and so forth it doesnt matter if list has odd or even num of elements.
The idea i have is to declare another function inside this function that takes to lists as input original list and its revers .but i cant seem to figure out how to correctly write the function

Here is the code
let rec lip l =
match l with
| [] -> []
| h::_ -> let rec w (l ,l1 ,i) =
let l1=List.rev l in let i =2 in
if (List.length l)/i > 0 then
[(List.hd l ,List.hd l1)]@w(List.tl l,List.tl l1 ,(i+1))
else []
this is how far i managed to write it
theoretically this idea should work but as i am a beginner i have a hard time with the syntax and a looked for simmilar examples and tutorials but didnt find what i needed
ps.if the list has odd number of elements the middle one is ignored

Hi there. You’re not using the w function you’re definining in your match case. What the match case is doing is creating a function, but as the previous match case returns a list, your last match case should return a list too, so your code should look like this :

let rec w (l, l1, i) =
  (* function body *)
w (* something *)

NB : I’m just discussing syntax and typing here, nothing to do with the content of your code.

thanks for your help now it works