Generation

generate functionSat, 12 Nov 2022

Compute the factorial of a number in one line in an anonymous function with type annotations

fn factorial(n: i32) -> i32 { (1..n + 1).fold(1, |acc, x| acc * x) }

Questions about programming?Chat with your personal AI assistant