Jump to content

Currying: Difference between revisions

No edit summary
Line 1,045:
{{out}}
<pre>-1</pre>
 
=={{header|Phix}}==
Phix does not support currying. The closest I can manage is very similar to my solution for closures
<lang Phix>sequence curries = {}
function create_curried(integer rid, sequence partial_args)
curries = append(curries,{rid,partial_args})
return length(curries) -- (return an integer id)
end function
 
function call_curried(integer id, sequence args)
{integer rid, sequence partial_args} = curries[id]
return call_func(rid,partial_args&args)
end function
 
function add(atom a, b)
return a+b
end function
 
integer curried = create_curried(routine_id("add"),{2})
printf(1,"2+5=%d\n",call_curried(curried,{5}))</lang>
{{out}}
<pre>
2+5=7
</pre>
<small>(Of course you would probably not have to try too much harder to make it say 2+2=5 instead.)</small>
 
=={{header|PicoLisp}}==
7,820

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.