When a language qualifies as a functional language? [closed] - functional-programming

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
What are the traits a language should have to be qualified as a functional language? When we can say that a language XYZ supports functional paradigm?

What are the traits a language should have to be qualified as a functional language? When we can say that a language XYZ supports functional paradigm?
Those are two different question. I'd say that "supporting functional paradigm" means:
you can work with functions like with other types (use them in local variables, parameters, …)
you can define anonymous functions (a.k.a. lambda functions) inline
anonymous functions can access variables declared in their environment (this is known as closure)
By this definition, pretty much any modern mainstream programming language supports the functional paradigm (with the exception of C).
To be classified as "functional language", a language needs to focus on the functional paradigm as its primary or only paradigm, including immutability and focus on pure (side-effect-free) functions. Apart from the above, this usually means:
support for declaring immutable types like discriminated unions
support for pattern matching
function bodies are composed of expressions, not statements

Related

Exactly what type of programming language is R? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
Like for example, python is fundamentally an object oriented language, i.e. everything including it's fundamental data types are objects. It supports all OO concepts like encapsulation, inheritance etc. Then on top of it has emulated procedural constructs and half-baked functional programming constructs like higher order functionals.
C is fundamentally a portable assembly language that allow abstract notions of targeting and manipulating memory using it's pointer language.
Wolfram language is fundamentally a term rewriter where it's fundamental data structure is expression with head and parts. It uses full pattern matching language like regex to define rules for it's expressions and uses infinite evaluation until its expressions stops changing, i.e. a fixed point is reached. Its general term rewrite allow it to emulate full procedural and functional language.
Now my question is what exactly is R language at a fundamental level? Does it have a fundamental representation of it's data types and everything? What is it's primary programming paradigm and what other paradigm it is just emulating? What programming constructs are completely available and what are half-baked?

Is using for-statements in R considered bad style? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
R is a functional programming language. Many for-statements can be replaced by one of the apply-functions. Thus, isn't the for-statement against the functional programming paradigm? Is using for-statements considered bad style, in the sense of functional programming?
Yes, a for loop is against the functional programming paradigm. However, R is not a pure functional programming language. It allows side effects.
There are scenarios where a for loop is appropriate. In particular, if you don't need a return value, but only a side effect such as plotting or exporting files, for loops are more appropriate than *apply functions.
Then there are some tasks that a just easier to solve with a for loop. E.g., if you look at the source of the Reduce function you'll find a for loop.

Recursion When to use it? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
So we just finished the subject recursion in school and I am still wondering "why?".
I feel like I have just learned a hell of a lot about math in a programming way with the sole purpose of passing an exam later on and then never again.
So what I want to know is when to use it? I can only find people saying "when you want to call a function within itself" but why would you do that?
Recursion is the foundation of computation, every possible program can be expressed as a recursive function (in the lambda calculus). Hence, understanding recursion gives you a deeper understanding of the principles of computation.
Second, recursion is also a tool for understanding on the meta level: Lots of proofs over the natural numbers follow a pattern called "natural induction", which is a special case of structural induction which in turn allows you to understand properties of very complex systems in a relatively simple way.
Finally, it also helps to write good (i.e. readable) algorithms: Whenever there is data to store/handle in a repetitive calculation (i.e. more than incrementing a counter), you can use a recursive function to implicitly manage a stack for you. This is also often very efficient since most systems come with a machine stack at hand.

Explain how the functional programming model differs from the procedural or object orientated models [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Can anyone explain how the functional programming model differs from the procedural or object orientated models.
I cannot conclude a good answer myself.
in my opinion FP is about pure functions (that is functions in a mathematical sense) - which implies referential transparency and, if you continue the thouhgt, immutable data.
This is the biggest difference I see: you don't mutate data - and most other aspects either directly follow from this or from cool type-systems (which are not necessary for a language to be called functional) and the academic nature.
But of course there is far more to it and you can read papers, complete books or just wikipedia about it.
please note that you can dispute the pure property and then things get a lot more fuzzy ... which should not surprise you, as most functional languages in wide to allow for mutation (Clojure, Scala, F#, Ocaml, ...) and there are not many pure ones.
In this case the biggest difference might be the way you abstract things with higher-order-functions (at least functions should be first class citizens - meaning you can pass them around and have them as values).
But overall this question is really opinionated and will very likely be closed as to broad or something - maybe you should ask for details instead of the big picture

Are symbolic computation and functional programming related? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I was wondering if symbolic computation in Computer Algebra System (such as symbolic toolbox in Matlab, Mathematica) and functional programming related and how? Does the former belong to the latter?
Thanks and regards!
They're different beasts. However, one point of overlap is term-rewriting languages such as pure ( http://code.google.com/p/pure-lang/ ). Pure can be used as a purely functional programming language. However, since it is implemented by term rewriting rather than graph reduction, its expressions are always able to be pattern-matched into their bits and transformed. This sort of symbolic manipulation is one of the key features of computer algebra systems. That said, a great deal of the power of computer algebra systems comes from having lots and lots of math baked in, and especially having powerful algorithms baked in for solving various tricky problems. You could write libraries to do that in functional languages (and algebraic data types would make it more pleasant than in imperative ones), but you'd still need to write those libraries.
These two concepts are not necessarily related. However, you might find interesting the fact that the Lisp programming language designed by John McCarthy in 1958 was influenced by the lambda calculus. Also that year, McCarthy published An Algebraic Language for the Manipulation of Symbolic Expressions where a very simple symbolic differentiation program was presented (see Appendix I). Therefore, you can see that the two concepts were very close at the beginning.

Resources