Catamorphism: Difference between revisions

→‎{{header|Lambdatalk}}: adding lambdatalk task
(Added another uBasic/4tH version)
(→‎{{header|Lambdatalk}}: adding lambdatalk task)
Line 1,631:
[15, -13, 120]
[15, 3, 120]</pre>
 
=={{header|Kotlin}}==
<syntaxhighlight lang="scala">fun main(args: Array<String>) {
Line 1,651 ⟶ 1,652:
Maximum : 5
</pre>
 
=={{header|Lambdatalk}}==
<syntaxhighlight lang="scheme">
{def nums 1 2 3 4 5}
-> nums
{S.reduce {lambda {:a :b} {+ :a :b}} {nums}}
-> 15
{S.reduce {lambda {:a :b} {- :a :b}} {nums}}
-> -13
{S.reduce {lambda {:a :b} {* :a :b}} {nums}}
-> 120
{S.reduce min {nums}}
-> 1
{S.reduce max {nums}}
-> 5
</syntaxhighlight>
 
=={{header|Logtalk}}==
The Logtalk standard library provides implementations of common meta-predicates such as fold left. The example that follow uses Logtalk's native support for lambda expressions to avoid the need for auxiliary predicates.
Line 1,786 ⟶ 1,804:
Maximum 5
</pre>
 
=={{header|Maple}}==
The left fold operator in Maple is foldl, and foldr is the right fold operator.
99

edits