Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
43
Task/Function-composition/Argile/function-composition.argile
Normal file
43
Task/Function-composition/Argile/function-composition.argile
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
use std, math
|
||||
|
||||
let my_asin = new Function (.:<any,real x>:. -> real {asin x})
|
||||
let my__sin = new Function (.:<any,real x>:. -> real { sin x})
|
||||
let sinasin = my__sin o my_asin
|
||||
print sin asin 0.5
|
||||
print *my__sin 0.0
|
||||
print *sinasin 0.5
|
||||
~my_asin
|
||||
~my__sin
|
||||
~sinasin
|
||||
|
||||
=: <Function f> o <Function g> := -> Function {compose f g}
|
||||
|
||||
.:compose <Function f, Function g>:. -> Function
|
||||
use array
|
||||
let d = (new array of 2 Function)
|
||||
(d[0]) = f ; (d[1]) = g
|
||||
let c = new Function (.:<array of Function fg, real x>:. -> real {
|
||||
*fg[0]( *fg[1](x) )
|
||||
}) (d)
|
||||
c.del = .:<any>:.{free any}
|
||||
c
|
||||
|
||||
class Function
|
||||
function(any)(real)->(real) func
|
||||
any data
|
||||
function(any) del
|
||||
|
||||
=: * <Function f> <real x> := -> real
|
||||
Cgen "(*("(f.func)"))("(f.data)", "(x)")"
|
||||
|
||||
.: del Function <Function f> :.
|
||||
unless f.del is nil
|
||||
call f.del with f.data
|
||||
free f
|
||||
=: ~ <Function f> := {del Function f}
|
||||
|
||||
.: new Function <function(any)(real)-\>real func> (<any data>):. -> Function
|
||||
let f = new Function
|
||||
f.func = func
|
||||
f.data = data
|
||||
f
|
||||
Loading…
Add table
Add a link
Reference in a new issue