|
Re: assorted beginner questions: msg#00502lang.scala
On 1/28/07, martin odersky odersky-at-......... |scala| <...> wrote: > for the following code: why doesn't the for-comprehension iterate over everything by default? or why not enforce map() always return an iterator? or have for-comprehensions use elements()? > is there any special syntax for hashtable/map/set gets/updates? what's the () operator? (m("d") in the examples.) i.e., what am i looking for in the api docs? or is this a language-level translation? i'm pretty amazed at how fast development on this language is moving. i just downloaded 2.3.0 what seemed like a few days ago, and in 2.3.2 all these and other changes were introduced. and now there's 2.3.3. > why is, e.g., foldLeft defined so oddly? 'explicitly curried', it seems: indeed, scala> def f[T,U](s:Set[U],a:T,b:(T,U)=>T):T=(s foldLeft a)(b) f: [T,U](scala.collection.immutable.Set[U],T,(T, U) => T)T scala> f(Set(1,2,3),0,((x,y)=>x+y)) <console>:5: error: missing parameter type val line10 = f(Set(1,2,3),0,((x,y)=>x+y)) ^ <console>:5: error: missing parameter type val line10 = f(Set(1,2,3),0,((x,y)=>x+y)) for some reason, the inference breaks if you try to lump the args together. it's unclear to me whether this is a limitation of the implementation or scala's type system.
i also was actually referring to the use of (...) and {...} (not empty; they have stuff between them). to use the above example: (Set(1,2,3) foldLeft 0) ((x,y) => x+y) (Set(1,2,3) foldLeft 0) {(x,y) => x+y} {Set(1,2,3) foldLeft 0} ((x,y) => x+y) {Set(1,2,3) foldLeft 0} {(x,y) => x+y} > is there any way to automatically inherit certain behaviors, a la does anybody have more info about this? do the combinators use scala.reflect?
although the shootouts are flawed in many ways, the ratio of Java:Scala speed seems to be consistently non-negligible across the shootouts: 1.7:2.6. yang |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Best Java library for parsing email messages?: 00502, Warren Henning |
|---|---|
| Next by Date: | Re: Implicit type conversion: 00502, martin odersky |
| Previous by Thread: | Re: assorted beginner questionsi: 00502, Lex Spoon |
| Next by Thread: | Re: assorted beginner questions: 00502, Philipp Haller |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |