プロシージャ データ型を作成します。
シグネチャ
説明
例
{do
|| Declare the variable my-proc to be a procedure
|| that takes one int argument and returns an int.
let my-proc:{proc-type {int}:int}
|| Set my-proc to the anonymous procedure that
|| takes one int (x) as an argument and returns
|| an int.
set my-proc = {proc {x:int}:int
{return 3 * x}
}
}
{do
|| Declare the variable my-proc to be a procedure
|| that takes one int argument and returns an int
|| and initialize it with an anonymous procedure.
let my-proc:{proc-type {int}:int} =
{proc {x:int}:int
{return 3 * x}
}
}
{define-proc {twice x:int}:int
{return x * 2}
}
{do
|| Declare the variable my-proc to be a procedure
|| that takes one int argument and returns an int
|| and initialize it with a named procedure:
let my-proc:{proc-type {int}:int} = twice
|| Call it.
{output {my-proc 3}}
}