Catamorphism: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
(add BQN) |
||
Line 410: | Line 410: | ||
<pre>28 |
<pre>28 |
||
5040</pre> |
5040</pre> |
||
=={{header|BQN}}== |
|||
BQN has two different primitives for catamorphism: |
|||
- Fold(<code>´</code>): Works on lists only. |
|||
- Insert(<code>˝</code>): Works on arrays with higher rank. |
|||
Both of these primitives take a dyadic function, and an optional initial element. |
|||
<pre>•Show +´ 30‿1‿20‿2‿10 |
|||
•Show +˝ 30‿1‿20‿2‿10 |
|||
•Show tab ← (2+↕5) |⌜ 9+↕3 |
|||
•Show +˝ tab</pre> |
|||
<pre>63 |
|||
┌· |
|||
· 63 |
|||
┘ |
|||
┌─ |
|||
╵ 1 0 1 |
|||
0 1 2 |
|||
1 2 3 |
|||
4 0 1 |
|||
3 4 5 |
|||
┘ |
|||
⟨ 9 7 12 ⟩</pre> |
|||
=={{header|Bracmat}}== |
=={{header|Bracmat}}== |