Skip to content
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

Image.map is confusing #2

Open
non opened this issue Oct 21, 2013 · 1 comment
Open

Image.map is confusing #2

non opened this issue Oct 21, 2013 · 1 comment

Comments

@non
Copy link

non commented Oct 21, 2013

So it seems like Image.map takes the size of the old image, but a new (Int, Int) => A function which it uses (ignoring the old raster's function).

This is a bit odd, right? I would imagine the map method as looking something more like this:

trait Image[A] { self =>
  ...
  def map[B](f: A => B): Image[B] = new Image[B] {
    def width = self.width
    def height = self.height
    def apply(x: Int, y: Int): B = f(self(x, y))
  }
}

I feel like the current map maybe belongs in a companion object? What is the advantage over just doing this:

object Image {
  def apply[A](w: Int, h: Int)(f: (Int, Int) => A): Image[A] = ...
}

What do you think?

@stephenjudkins
Copy link
Owner

You're right. I should get rid of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants