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

5 Likes

A possible solution.

2 Likes

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.