Currying: Difference between revisions

Added FreeBASIC
(Added FreeBASIC)
Line 377:
{{out}}
<pre>10 12</pre>
 
=={{header|FreeBASIC}}==
FreeBASIC is not a functional language and does not support either currying or nested functions/lambdas which are typically used by otherwise imperative languages to implement the former. The nearest I could get to currying using the features which the language does support is the following:
<lang freebasic>' FB 1.05.0 Win64
 
Type CurriedAdd
As Integer i
Declare Function add(As Integer) As Integer
End Type
 
Function CurriedAdd.add(j As Integer) As Integer
Return i + j
End Function
 
Function add (i As Integer) as CurriedAdd
Return Type<CurriedAdd>(i)
End Function
 
Print "3 + 4 ="; add(3).add(4)
Print "2 + 6 ="; add(2).add(6)
Sleep</lang>
 
{{out}}
<pre>
3 + 4 = 7
2 + 6 = 8
</pre>
 
=={{header|Go}}==
9,490

edits