Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ブーでラムダをどのように扱いますか? 「callable」は同じことですか?ラムダをパラメーターとして受け取るメソッドをどのように定義しますか?
Booはラムダ式の構文をサポートしています:
foo = {x|x+2} seven = foo(5) def TakeLambda(expr as callable(int) as int): return expr(10) twelve = TakeLambda(foo)
この例でfooは、は数値xを受け入れ、x + 2を返す関数です。したがって、呼び出しfoo(5)は数値7を返します。これは、数値xを受け入れ、10で評価TakeLambdaする関数です。foo
foo
foo(5)
TakeLambda