blog podcast

Functional

I’m practicing algorithms and get a problem which I find quite hard. In addition I’m trying to implement the solution in Rust, which is not a language I’m using so often, and it’s not a language I’ve used for a long time. When doing this I’m realizing one of the big strengths of Functional programming, namely testing.

When you know how you want to implement an algorithm the natural thing is to break it down into as small pieces as possible. This is something you always do, regardless of working with functional programming or not. With functional programming though, since you typically solve problems by combining different functions, it is easier to test your overarching logic, since you can mock you subparts better.

Code of the Day

Although it makes my head hurt again, it’s kind of nice to say hello to rust code once more.

        match pres_sums.get(e) {
            Some(v) => {
                for vi in v {
                    let mut trip = vi.clone();
                    insert_sorted(&mut trip, *e);
                    ans.insert(trip);
                }
            },
            _ => ()
        };