buzz-language / buzz

👨‍🚀 buzz, A small/lightweight statically typed scripting language
https://buzz-lang.dev
MIT License
1.15k stars 31 forks source link

Merge functional helpers behind a common iterator interface #214

Open giann opened 8 months ago

giann commented 8 months ago

Right now lists and maps have their own version of map, filter, reduce, etc.

We could imagine a common iterator interface supported by fibers that both could implement. This way any user defined object could also implement that interface.

var filtered = [1, 2, 3]
    .iter()
    .filter(
        fun (int i, int element) -> element % 2 == 0
    );