News for hackers. Stuff that matters.
Re:Go proposal: new package to provide generic slice functions by creata on Wednesday May 05, 2021 @11:02AM (#27050756)
Alright, if it's not too much trouble, can you show me what the equivalent of the following code would be in Go? I think this is extremely clear as-is, but I'd love to see how you can apparently make it even clearer by avoiding iterator combinators.

https://play.rust-lang.org/?version=nightly&mode=release&edi...

Re:Go proposal: new package to provide generic slice functions by throwaway894345 on Wednesday May 05, 2021 @12:13PM (#27051813)
Personally I think this is clearer, but it's quite contrived either way: https://play.golang.org/p/FpUWwm5yZ8n
Re:Go proposal: new package to provide generic slice functions by creata on Wednesday May 05, 2021 @12:39PM (#27052187)
Nice! Out of curiosity, if the iterators weren't of the same type (e.g. one was an iterator over the values of a hashmap and the other was over the items in a list) what would you have used instead of

    for _, m := range maps { ... }?
Re:Go proposal: new package to provide generic slice functions by throwaway894345 on Wednesday May 05, 2021 @02:07PM (#27053461)
Just as with Rust, you'd have to convert both maps to the same type before you could iterate them over together (or chain them, in Rust).
Re:Go proposal: new package to provide generic slice functions by coder543 on Wednesday May 05, 2021 @01:57PM (#27053300)
If you could provide the hypothetical Rust code you're referring to, that would probably make your question more clear here. I know both Rust and Go rather well, and I'm confused about which direction you're wanting to take the code.