Misplaced Pages

Comparison of programming languages (functional programming)

Article snapshot taken from[REDACTED] with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
(Redirected from Comparison of programming languages (functional instructions))
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
This article's factual accuracy is disputed. Relevant discussion may be found on the talk page. Please help to ensure that disputed statements are reliably sourced. (July 2015) (Learn how and when to remove this message)
This article relies largely or entirely on a single source. Relevant discussion may be found on the talk page. Please help improve this article by introducing citations to additional sources.
Find sources: "Comparison of programming languages" functional programming – news · newspapers · books · scholar · JSTOR (July 2015)
This article possibly contains original research. Please improve it by verifying the claims made and adding inline citations. Statements consisting only of original research should be removed. (July 2015) (Learn how and when to remove this message)
This article provides insufficient context for those unfamiliar with the subject. Please help improve the article by providing more context for the reader. (April 2016) (Learn how and when to remove this message)
The article's lead section may need to be rewritten. Please help improve the lead and read the lead layout guide. (April 2016) (Learn how and when to remove this message)
(Learn how and when to remove this message)
Comparison of
programming languages

Comparison of individual
languages

This page provides the comparison tables of functional programming instructions between programming languages. Comparison of basic instructions of imperative paradigm is provided by the comparison of basic instructions.

List operations

Function applications and lists

For brevity, these words will have the specified meanings in the following tables (unless noted to be part of language syntax):

funcN
A function. May be unary or n-ary (or always unary for languages without n-ary functions).
func1, func2, etc.
functions of specific arity. func (with no number) is the same as func1, also known as a projection in many languages.
pred
Unary function returning a Boolean value. (ML type: 'a -> bool) (C-like type: bool pred<T>(T t)).
list
The list being operated on.
args
Comma-separated list of one or more argument names, in the form of arg1, arg2, ..., argn.
pattern
A pattern, in languages with pattern matching.
val
Any relevant value, depending on context.
identity lambda lambda map apply filter fold sum
Python lambda x: x lambda args: expr map(func, list) nfunc(*arguments) filter(pred, list) functools.reduce(func2, list) sum(list)
Mathematica #& (expr)& (arguments are #1, #2, etc.)

Function

Map

func /@ list

Apply

nfunc@@args

Select Fold Apply

Plus@@list

C# x => x (args) => expr Enumerable.Select(list, func) Requires reflection Enumerable.Where(list, pred) Enumerable.Aggregate(list, func2)

Enumerable.Aggregate(list, val, func2)

Enumerable.Sum(list)

Enumerable.Sum(list, func)

Visual Basic .NET Function(x) x Function(args) expr
F# (can use Enumerable as well) id(built-in)

fun x -> x

fun pattern -> expr Seq.map func list Seq.filter pred list Seq.fold func2 val list Seq.sum list

Seq.sumBy func list

Numerical operations on lists

comp
a binary function that returns a value indicating sort order (an integer in most languages).
sort max min
Python sorted(list) max(list) min(list)
Mathematica Sort Max Min
C# Enumerable.OrderBy(list, comp) Enumerable.Max(list, func) Enumerable.Min(list, func)
Visual Basic .NET
F# Seq.sort list

Seq.sortBy comp list

seq.max

seq.maxBy func list

seq.min

seq.minBy func list

Iterations on lists

group by
Python itertools.groupby(list, func)
Mathematica GroupBy
C# Enumerable.GroupBy(list, func)
Visual Basic .NET
F# seq.groupBy func list

Generating lists by combinatorics tools

start
first value of range.
step
increment of range.
count
number of items in range.
last
inclusive last value of range.
end
exclusive last value of range.
Generate range (lazily) Infinite range (lazily)
Python xrange(start, end, step) (Python 2)

range(start, end, step) (Python 3)

itertools.count(start, step)
C# Enumerable.Range(start, count) Enumerable.Range(start, Int32.MaxValue)
Visual Basic .NET
F# seq { start..step..last } Seq.initInfinite func

References

  1. ^ "Enumerable Class (System.Linq)". Microsoft Docs. Microsoft. Retrieved 2019-08-29.
  2. ^ "Collections.Seq Module (F#)". Microsoft Developer Network. Microsoft. Retrieved 2019-08-29.
  3. "itertools — Functions creating iterators for efficient looping". Python 3.7.4 documentation. Python Software Foundation. Retrieved 2019-08-29.
  4. "Built-in Functions". Python 2.7.16 documentation. Python Software Foundation. Retrieved 2019-08-29.
  5. "Built-in Types". Python 3.7.4 documentation. Python Software Foundation. Retrieved 2019-08-29.
  1. "GroupBy". Wolfram Language Documentation. Wolfram. Retrieved 2019-08-29.


Stub icon

This programming-language-related article is a stub. You can help Misplaced Pages by expanding it.

Categories:
Comparison of programming languages (functional programming) Add topic