Function composition: Difference between revisions

Line 372:
 
=={{header|ATS}}==
 
I assume from the description of the task that the mere application of two functions in succession is not the goal. That, instead, the composition of two closures or closure-like objects is ''required''.
 
(In other words, the idea is "How can we compose two functions that have ''implicit'' environments and get a new function that has an ''implicit'' environment".)
 
 
<lang ats>(*
Line 408 ⟶ 413:
main0 () =
let
val fone_hundred = (lam y =<cloref1> add_double_int (100.0, y))
val gchar_zero = (lam x =<cloref1> char2i x - char2i '0')
val f = (lam y =<cloref1> add_double_int (one_hundred, y))
val g = (lam x =<cloref1> char2i x - char2i char_zero)
val z = compose (f, g) ('5')
in
Line 418 ⟶ 425:
<pre>$ patscc -O2 -DATS_MEMALLOC_GCBDW function_composition.dats -lgc && ./a.out
105.000000</pre>
 
 
 
=={{header|AutoHotkey}}==
1,448

edits