4 ms·
Input is an obvious example, as it's impossible to predict the value of an input. Do you mean this more abstractly or literally? In the example of PacMan, for
by jibe 3y ago
Input is an obvious example, as it's impossible to predict the value of an input.
Do you mean this more abstractly or literally? In the example of PacMan, for every frame, the only possible input is nothing, left, right, up, or down. So you are be able to predict it is going to be one of those five, though not which one.
- mrkeen 3y ago> Do you mean this more abstractly or literally? >> Input is an obvious example, as it's impossible to predict the value of an input. > though not which one Literally.
- jibe 3y agoI’m asking as someone not familiar with function programming, so trying to learn, not be pedantic, btw! So because the possible input is not just a single value, it is not predictable. It doesn’t matter if the input was limited to a set of two values, or infinite, it is literally not predictable so therefore we don’t know the future state of the program?
- epgui 3y agoThat’s right! You can consider the user input a source of randomness even if it can only take two values, like heads or tails.
- TuringTest 3y agoThat is unpredictable, but not a side effect. Side effects are changes that are not declared as part of the function parameters. If you model the controller input as a function parameter, that's just a state argument, and FP can handle it declaratively just fine without having side effects.