Mar. 29th, 2010

juan_gandhi: (Default)
Кто-нибудь заметил ещё? Плавная такая волна прошла, и ещё, и ещё.
juan_gandhi: (Default)
blogger entry

  trait Functor[X] { 
    def map[Y](f: X => Y): Functor[Y]
  }
  
  def loop[X,Y](f: Functor[X], a: X=>Y) = for (x <- f) yield a(x)


Update: see recent blog entry on monads by Luc Duponchel for a lot more details.

Update: did you get it? for() can be applied to any class that has map(); and, roughly speaking, if you have several variables in your for loop, you will need flatMap (to flatten the result, aka, apply monadic multiplication.

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

November 2025

S M T W T F S
       1
2345678
9101112131415
16171819202122
23242526272829
30      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Nov. 3rd, 2025 03:57 pm
Powered by Dreamwidth Studios