Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Results tagged with functional-programming
Search options not deleted
user 121035
Functional programming is a paradigm which attempts to solve computational problems by the chained evaluation of functions whose output is determined by their inputs rather than the programme state. In this style of programming, side effects and mutable data are deprecated and usually strictly isolated.
3
votes
Is it possible to reason about memory just by looking at type signatures?
No, the Halting Problem strikes again:
fn add(n: Int, ns: [Int]) -> [Int] {
if halts(add) {
loop {}
}
return ns.map(|v| {v+n})
}
Depending on if add halts or not, it will alloc …
6
votes
Functional style exception handling
As long as there are no externally visible side effects and the return value depends exclusively on the inputs, then the function is pure, even if it does some rather impure things internally.
So it …
6
votes
Is a function getting a value from another function considered pure?
Yes, those are both pure functions (assuming the elided part is also pure) because:
The result depends only on the parameters.
There are no side effects.
Note that if getDefaultSeparator() was not …
0
votes
Why it is `(cons 1 (cons 2 (cons 3 nil)))` and not `(cons 3 (cons 2 (cons 1 nil)))` for [1,2...
We use the first method because it produces the correct list. The second produces a reversed list. The nil very clearly shows which element must be the last.
The order matters!
See this trivial exampl …