Function composition: Difference between revisions
→{{header|ATS}}
Line 373:
=={{header|ATS}}==
If I may state in greater detail what the task requires, it is this:
That '''compose''' should return ''a new function'', which will exist independently of '''compose''' once created. A person should never have to call '''compose''' merely to get the result of the composed computation.
Thus it is probably impossible, for instance, to satisfy the requirement in standard C, although there are system-dependent libraries that can create closures for C.
<lang ats>(*
Line 418 ⟶ 419:
val g = (lam x =<cloref1> char2i x - char2i char_zero)
val z = compose (f, g) ('5')
val fg = compose (f, g)
val w = fg ('7')
in
println! (z : double);
println! (w : double)
end</lang>
{{out}}
<pre>$ patscc -O2 -DATS_MEMALLOC_GCBDW function_composition.dats -lgc && ./a.out
105.000000
107.000000</pre>
=={{header|AutoHotkey}}==
|