-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List: higher level functions #37
Conversation
Some open points:
func immutable.MapTo[F any, T any](from immutable.List[F], mapper func (F) T) List[T] { ... } |
|
@laher Sorry for the delay. I'm still planning on reviewing this and it's in my TODO list. It'll probably be later this week though. |
Hey. I don't think I'm keen on using this library any more, so I'm closing this. You're welcome to reopen & merge the PR, but I've decided this library isn't for me. I think what I really want is something more like the Guava (Java) immutable collections rather like than like immutable.js, i.e. no 'add/delete' support is needed, and none of the internal smarts for efficient modifications. Just a thin layer to provide convenient & read-only access to maps/slices, and a way to get a copy of the data back out again. I might work on something like that instead. Sorry for the issue with the previous PR with the varargs, I misunderstood the Cheers |
Thanks for your work, @laher! 🙏 |
Some #27 for Lists
.Map(), .Filter(), .Each(). Seems enough for many use cases.
Each()
provides the means to approximate other HOFs like Reduce - you could use a closure on a target variable.Note that Go generics don't allow you to introduce a new generic type in method definitions (although bare functions are allowed to declare generic types), so we're limited in what we can do in these methods. So it's not straightforward to .Map() to a list of a different type, or to .Reduce() to a different type. It's easiest to just support
Each()
and leave it to the caller to use closures.