Which languages support *recursive* function literals / anonymous functions?

后端 未结 16 2150
一整个雨季
一整个雨季 2021-02-04 05:09

It seems quite a few mainstream languages support function literals these days. They are also called anonymous functions, but I don\'t care if they have a name. The important th

16条回答
  •  终归单人心
    2021-02-04 05:47

    In Perl 6:

    my $f = -> $n { if ($n <= 1) {1} else {$n * &?BLOCK($n - 1)} }
    $f(42);  # ==> 1405006117752879898543142606244511569936384000000000
    

提交回复
热议问题