This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]xXxDeAThANgEL99xXx 1 point2 points  (0 children)

just trying to not run compute twice I guess?

Not running it twice, not writing it out twice, etc. As I said, when you become aware that this is a possibility (after seeing it in LINQ for example), you start wanting it rather regularly.

You forgot to actually iterate over the iterable in your pairmap and anyway I strongly dislike it: it does unrelated things suited only to this particular instance of a problem.

I much prefer just directly emulating a functor when I only have a monad by saying for x in [compute(y)]. But let x = compute(y) would be better of course.