Comparison of programming languages (functional programming)

Programming language comparisons

* General comparison
* Assignment
* Basic syntax
* Basic instructions
* Comments
* Control flow
* Foreach loops
* While loops
* For loops
* Do-while
* Exception handling
* Enumerated types
* Generators
* Anonymous functions
* Conditional expressions
* Functional instructions
* Arrays
* Associative arrays
* Scope
* String operations
* String functions
* Higher-order functions
* Type systems
* List comprehension
* Object-oriented programming
* Object-oriented constructors
* Operators

* Evaluation strategy
* List of "Hello World" programs

* Languages with dependent types
* Comparison of type systems

* * *

Comparison of individual languages

* ALGOL 58's influence on ALGOL 60
* ALGOL 60: Comparisons with other languages
* Comparison of ALGOL 68 and C++
* ALGOL 68: Comparisons with other languages
* Compatibility of C and C++
* Comparison of Pascal and Borland Delphi
* Comparison of Object Pascal and C
* Comparison of Pascal and C
* Comparison of Java and C++
* Comparison of C# and Java
* Comparison of C# and Visual Basic .NET
* Comparison of Visual Basic and Visual Basic .NET

* v
* t
* e

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.

## Contents

* 1 List operations
* 1.1 Function applications and lists
* 1.2 Numerical operations on lists
* 1.3 Iterations on lists
* 1.4 Generating lists by combinatorics tools
* 2 References

## 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[{args},expr]

| Map[func, list]

func /@ list

| Apply[nfunc, args]

nfunc@@args

| Select[list, pred] | Fold[func2, val, list] | Apply[Plus,list]

Plus@@list

C#[1] | 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[1] | Function(x) x | Function(args) expr
F#[2] (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[list] | Max[list] | Min[list]
C#[1] | Enumerable.OrderBy(list, comp) | Enumerable.Max(list, func) | Enumerable.Min(list, func)
Visual Basic .NET[1]
F#[2] | 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)[3]
Mathematica  | GroupBy[list, func][wolfram 1]
C#[1] | Enumerable.GroupBy(list, func)
Visual Basic .NET[1]
F#[2] | 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)[4]

range(start, end, step) (Python 3)[5]

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

## References

1. ↑ 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 "Enumerable Class (System.Linq)". Microsoft. https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.
2. ↑ 2.0 2.1 2.2 2.3 "Collections.Seq Module (F#)". Microsoft. https://msdn.microsoft.com/en-us/visualfsharpdocs/conceptual/collections.seq-module-[fsharp].
3. ↑ "itertools — Functions creating iterators for efficient looping". Python Software Foundation. https://docs.python.org/3/library/itertools.html#itertools.
4. ↑ "Built-in Functions". Python Software Foundation. https://docs.python.org/2/library/functions.html#xrange.
5. ↑ "Built-in Types". Python Software Foundation. https://docs.python.org/3/library/stdtypes.html#range.

1. ↑ "GroupBy". Wolfram. https://reference.wolfram.com/language/ref/GroupBy.html.en.

0.00

(0 votes)

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Comparison_of_programming_languages_(functional_programming)&oldid=4203750"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template