Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
28
Task/Function-composition/ATS/function-composition-2.ats
Normal file
28
Task/Function-composition/ATS/function-composition-2.ats
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include "share/atspre_staload.hats"
|
||||
|
||||
fn {t1, t2, t3 : t@ype}
|
||||
compose (f : t2 -<cloref1> t3,
|
||||
g : t1 -<cloref1> t2) : t1 -<cloref1> t3 =
|
||||
lam x => f (g (x))
|
||||
|
||||
fn
|
||||
compose_char2int2double
|
||||
(f : int -<cloref1> double,
|
||||
g : char -<cloref1> int) :
|
||||
char -<cloref1> double =
|
||||
compose<char, int, double> (f, g)
|
||||
|
||||
implement
|
||||
main0 () =
|
||||
let
|
||||
val one_hundred = 100.0
|
||||
val char_zero = '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_char2int2double (f, g) ('5')
|
||||
val fg = compose_char2int2double (f, g)
|
||||
val w = fg ('7')
|
||||
in
|
||||
println! (z : double);
|
||||
println! (w : double)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue