June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -3,12 +3,12 @@ import extensions.
|
|||
func1 extension op
|
||||
{
|
||||
compose(BaseFunction1 f)
|
||||
= (:x)(self eval(f eval:x)).
|
||||
= (:x)(self(f(x))).
|
||||
}
|
||||
|
||||
program =
|
||||
[
|
||||
var fg := (:x)(x + 1) compose(:x)(x * x).
|
||||
|
||||
console printLine(fg eval(3)).
|
||||
console printLine(fg(3)).
|
||||
].
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
compose[\A, B, C\](f:A->B, g:B->C, i:Any): A->C = do
|
||||
f(g(i))
|
||||
end
|
||||
|
||||
composed(i:RR64): RR64 = compose(sin, cos, i)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
alt_compose(f:Number->RR64, g:Number->RR64, i:RR64): ()->RR64 = do
|
||||
f(g(i))
|
||||
end
|
||||
|
||||
alt_composed(i:RR64): RR64 = compose(sin, cos, i)
|
||||
|
|
@ -0,0 +1 @@
|
|||
opr_composed(i:Number): Number->RR64 = (sin COMPOSE cos)(i)
|
||||
|
|
@ -0,0 +1 @@
|
|||
@show (asin ∘ sin)(0.5)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
compose(f::Function, g::Function) = (x) -> g(f(x))
|
||||
@show compose(sin, asin)(0.5)
|
||||
|
|
@ -1 +0,0 @@
|
|||
compose(f::Function, g::Function) = x->f(g(x))
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
sub triple($n) { 3 * $n }
|
||||
my &f = &triple ∘ &[-] ∘ { $^n + 2 };
|
||||
say &f(5); # Prints "-21".
|
||||
my &f = &triple ∘ &prefix:<-> ∘ { $^n + 2 };
|
||||
say &f(5); # prints "-21".
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue