Answer:
F# Code:
let rec prefix n list =
//Extracting head and tail elements
let valHead = (Listhead list)
let valTail = (Listtail list)
// Checking n value
match n with
| 0 -> []
| _ -> [valHead] at (prefix (n-1) valTail) // Creating list recursively
//Testing function
let lstT = [1; 2; 3; 4; 5]
printfn "%A" (prefix 3 lstT)
printfn "%A" (prefix 2 lstT)
printfn "%A" (prefix 4 lstT)
Step-by-step explanation: see attachment below for sample run