Tacit programming: Difference between revisions

Content deleted Content added
m jq: <code>: fix syntaxhighlight error
Functional programming: base case before the recursive case
 
Line 28:
===Functional programming===
A simple example (in [[Haskell]]) is a program which computes the sum of a list of numbers. We can define the sum function recursively using a ''pointed'' style (cf. [[value-level programming|''value''-level programming]]) as:
<syntaxhighlight lang="haskell">sum [] = 0
sum (x:xs) = x + sum xs</syntaxhighlight>
sum [] = 0
</syntaxhighlight>
 
However, using a [[fold (higher-order function)|fold]], this can be replaced with: