Can I put let statements in an F# list comprehension?
f#
Solution
I would just skip the list comprehension.
let ys = xs |> List.map f |> List.filter g
However it is simple enough to get your code working.
let ys = [ for x in xs do
let y = f(x)
if g(y) then yield y ]
Problem
I am trying to write a list comprehension in F# and can't get it to compile: ``` [for x in xs do let y = f(x) when g(y) -> y] ``` Is there any way to save an intermediate computation in the middle of a list comprehension? How can I rework this list comprehension so that it compiles?