can anyone help me with this F# code? I am a F# beginner and I have a problem with it.
Big thanks
let rec rem l xs = match xs with
| [] -> []
| x::xs -> if x>l then rem l y
else x::(rem l y)
let rec minfree1 l:long xs = match xs with
| [] -> 1
| _ -> let nxs = rem xs l
let l1 = List.length(nxs)
in if l1=l then (l+1)
else minfree1 l1 nxs
let minfree xs = minfree1 (List.length(xs)) xs
And you’re writing using low-level idioms when higher-level programming will do much better. For example
Your algorithm (minfree1) is also doing multiple passes on your data (once for computing the length, another for filtering, repeat). If you actually worked on the pair of the list and its length, this would be faster. In any case, this looks like a task where some actual data-structure will be needed [lists are functional program’s assembly-level…]