Type challenge!

Let's define natural numbers as following:

    let zero: [i32;0] = [];
    let one: [[i32;0];0] = [];
    let two: [[[i32;0];0];0] = [];
    let three: [[[[i32;0];0];0];0] = [];

Challenge: write addition function (or closure) capable of returning sum of two numbers.

assert_eq!(add(two,one), three);

(it should work for any previously defined number!)

1 Like

Here's my solutions:

On stable: Rust Playground

On nightly: Rust Playground


A possible solution.


Wow. Really cool!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.