F# - Function with no arguments?
Posted
by Rubys
on Stack Overflow
See other posts from Stack Overflow
or by Rubys
Published on 2010-05-09T12:55:51Z
Indexed on
2010/05/09
12:58 UTC
Read the original article
Hit count: 160
When thinking in a functional mindset, given that functions are supposed to be pure, one can conclude any function with no arguments is basically just a value.
However, reallity gets in the way, and with different inputs, I might not need a certain function, and if that function is computationally expensive, I'd like to not evaluate it if it's not needed.
I found a workaround, using let func _ = ...
and calling it with func 1 or whatever, but that feels very non-idiomatic and confusing to the reader.
This boils down to one question: In F#, Is there a proper way to declare a function with zero arguments, without having it evaluated on declaration?
© Stack Overflow or respective owner