Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Function-composition/Transd/function-composition.transd
Normal file
29
Task/Function-composition/Transd/function-composition.transd
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#lang transd
|
||||
|
||||
MainModule: {
|
||||
// Make a short alias for a function type that takes a string and
|
||||
// returns a string. Call it 'Shader'.
|
||||
|
||||
Shader: typealias(Lambda<String String>),
|
||||
|
||||
// 'composer' function takes two Shaders, combines them into
|
||||
// a single Shader, which is a capturing closure, аnd returns
|
||||
// this closure to the caller.
|
||||
// [[f1,f2]] is a list of captured variables
|
||||
|
||||
composer: (λ f1 Shader() f2 Shader()
|
||||
(ret Shader(λ[[f1,f2]] s String() (exec f1 (exec f2 s))))),
|
||||
|
||||
_start: (λ
|
||||
// create a combined shader as a local variable 'render'
|
||||
|
||||
locals: render (composer
|
||||
Shader(λ s String() (ret (toupper s)))
|
||||
Shader(λ s String() (ret (+ s "!"))))
|
||||
|
||||
// call this combined shader as a usual shader with passing
|
||||
// a string to it, аnd receiving from it the combined result of
|
||||
// its two captured shaders
|
||||
|
||||
(textout (exec render "hello")))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue