Multiparadigm Language

No one programming style is ideally suited to every problem. Mathematica stands out from traditional computer languages by simultaneously supporting many programming paradigms, such as procedural, functional, rule-based, pattern-based, and more.

ADDITIVE GmbH, mathematica@additive-net.de, 06172-5905-30

Procedural (Fortran/Basic)

facProcedural[n_] :=
Block[ { i, s = 1},
	Do[s = s*i, {i, 1, n}];
	s
]

facProcedural[10]

ADDITIVE GmbH, mathematica@additive-net.de, 06172-5905-30

Recursive (C)

facRecursive[n_] := If[n == 0, 1, 
			n facRecursive[n-1]]

facRecursive[10]

ADDITIVE GmbH, mathematica@additive-net.de, 06172-5905-30

List-Based (APL, LISP)

facAPL[n_] := Times @@ Range[n]

facAPL[10]

ADDITIVE GmbH, mathematica@additive-net.de, 06172-5905-30

Rule - Based

facRule[n_] := n facRule[n-1]

facRule[0] = 1;

facRule[10]

ADDITIVE GmbH, mathematica@additive-net.de, 06172-5905-30