So I know that you can't directly get input from a user in a functional program because it obviously wouldn't be pure. But does this still apply if the user had only like 4 options to choose from? For instance, is it still impure if you're asking for hair color and there were four options to choose from: Brown, Black, Blonde, Red. If the user were to click a button corresponding to their hair color instead of typing it in, would that be considered pure?
Getting I/O in a functional program
113 Views Asked by skiboy108 At
1
There are 1 best solutions below
Related Questions in INPUT
- Player input not working properly in unity
- Getting data attributes from HTML input element with a datalist
- how to find sum of input value in javascript
- Terminal stimulation
- C#: creating an array and appending console input to each value
- How do i make a text inside disabled <v-text-field> selectable (simply to copy and paste somewhere else)?
- C++ File Input Skipping Lines
- React text box not taking input
- Trying to build a Generative Adversarial Network to generate images based on captions but facing errors with input shapes
- Video controls are hidden behind input feature?
- How can I edit a todo list on the same input where add todo in React?
- Stopping code while the input line is running
- Store Gum Input in variable?
- Detect password manager (or chromium) autofill for websites
- How can I make sure that my Selector does not overlap my text-area box when hover ? I would like for the selector to smoothly push down the text-area
Related Questions in FUNCTIONAL-PROGRAMMING
- On Google Sheets (and only built-in functions allowed, no Google Apps Script) Is it possible to simulate pipe function?
- Why does Enum require to implement toEnum and fromEnum, if that's not enough for types larger than Int?
- Is there a functional way to map a list (N elements) to a list of sums of adjacent elements (N - 1 elements) in Kotlin?
- How to count the occurences of every element in a list in Haskell fast?
- Combine lists with absolute index in functional programming
- How to refactor a loop with iterator. (Returning from closure)
- In Haskell, what does `Con Int` mean?
- Setting up different Java class fields value by a single value on some counter value
- Why doesn't map read show (Integer) work to separate each value in a string of Integers?
- Grouping by multiple fields and counting using in Java 8
- Variable capture: How variables behave in function closures
- Composing React Providers with Value props in Typescript
- How can atomicModifyIORef cause leaks? And why does atomicModifyIORef' solve the problem?
- How can I change XMobar's Kbd monitor plugin such that clicking on it loops throught the layouts?
- How to get success or error data without folding the response while using fpdart in flutter?
Related Questions in PURE-FUNCTION
- How can passing the `IO ()` to `main` be considered pure?
- Pure functional way of creating a std::optional counterpart
- Angular Change Detection and array.includes
- Can I make a pure Haskell function wait for 2 seconds?
- In functional programming, how to convert a function which uses global variables into a pure function?
- How pure should a function be when writing in React?
- How to implement db capability approach with pure functions in F#?
- Functions that have no effect on global state
- Getting I/O in a functional program
- why react UI Frameworks not use memo or PureComponent by defaults
- Member method calls virtual method with same name but different signature
- Is my usage of useEffect to generate array correct here?
- gcc 12 suggesting to add the "pure" attribute
- what are some potential dependencies or needs in pure functions?
- Can a React usestate update be nested in another useState functional update?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You can't predict what the user is going to choose, making the decision non-deterministic, and hence impure.
User input is essentially a function that has to produce a value out of nothing:
() -> HairColor.If you have four kinds of
HairColor, you can write exactly four pure functions of that type:None of them would, though, capture user input. In order to get the user input, you need another kind of 'argument' to the function:
but then, where does
UserInputcome from? It's not something you can compile into the program. It has to 'come from the outside', and every time you run the program, it may be different.