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

October 2025

S M T W T F S
    1 23 4
5 678 9 1011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Oct. 13th, 2025 12:58 pm
Powered by Dreamwidth Studios