Catamorphism: Difference between revisions

Add APL
(Add BCPL)
(Add APL)
Line 161:
-13
</pre>
 
=={{header|APL}}==
<em>Reduce</em> is a built-in APL operator, written as <code>/</code>.
 
<lang apl> +/ 1 2 3 4 5 6 7
28
×/ 1 2 3 4 5 6 7
5040</lang>
 
For built-in functions, the seed value is automatically chosen to make sense.
 
<lang apl> +/⍬
0
×/⍬
1
⌈/⍬ ⍝ this gives the minimum supported value
¯1.797693135E308</lang>
 
For user-supplied functions, the last element in the list is considered the seed.
If <code>F/</code> is called with a list of only one element, <code>F</code> itself is never
called, and calling <code>F/</code> with the empty list is an error.
 
<lang apl> {⎕←'Input:',⍺,⍵ ⋄ ⍺+⍵}/ 1 2 3 4 5
Input: 4 5
Input: 3 9
Input: 2 12
Input: 1 14
15
{⎕←'Input:',⍺,⍵ ⋄ ⍺+⍵}/ 1
1
{⎕←'Input:',⍺,⍵ ⋄ ⍺+⍵}/ ⍬
DOMAIN ERROR</lang>
 
=={{header|AppleScript}}==
2,096

edits