Suma

Czech Republic

Age: 43

Programmer

Areas of interest:

  • Native Win32 programming
  • Visual C++
  • Scala
  • C++ templates
  • Multicore scalability
  • DirectX, OpenGL, 3D graphics
  • Performance optimizations
5h
accepted Why return in getOrElse makes tail recursion not possible?
23h
comment Why warning when scala.language.implicitConversions is not the last import?
@Travis I think a specific (one-name) import has precedence over a wildcard import done before it.
23h
comment String interpolation in Scala 2.10 - How to interpolate a String variable?
I pasted all three lines into a Scala source. I cannot compile it unless I add type annotation to the name parameter.
1d
comment Why return in getOrElse makes tail recursion not possible?
I have tried it and this is rejected by the compiler as well.
1d
comment Why return in getOrElse makes tail recursion not possible?
I have added some more examples. What is the difference between the two map variants? Why map( return s ) compiles and map( x => return s ) does not?
1d
revised Why return in getOrElse makes tail recursion not possible?
Added more examples.
1d
comment Why return in getOrElse makes tail recursion not possible?
I am afraid I still do not see the reason. :( How is return in getOrElse different from return in e.g. Some(()).map( return s ), or in the getOrElse which is inlined? Also, are there some links listing the requirements you mentioned: " last call should be return or next call the same function"?
1d
revised Why return in getOrElse makes tail recursion not possible?
Added one more example which compiles.
1d
revised Why return in getOrElse makes tail recursion not possible?
Avoid deprecation warning in Some()
1d
revised Why return in getOrElse makes tail recursion not possible?
Added tailrec annotation for better clarity.
1d
revised Why return in getOrElse makes tail recursion not possible?
Some() looks nicer than Some(null)
1d
comment Why return in getOrElse makes tail recursion not possible?
In your own example you can replace case Nil => s with case Nil => return s and the function will still be compiled as tail recursive?
1d
asked Why return in getOrElse makes tail recursion not possible?
1d
comment String interpolation in Scala 2.10 - How to interpolate a String variable?
With Scala 2.11.5 the second line gives error "missing parameter type name". I think it needs to be written as val template = (name:Any)=>s"Hello $name" or def template(name:Any) = s"Hello $name"
Feb
27
comment Scala strip trailing whitespace
Note: split("\n") uses regex matching. Using split('\n') instead seems to convey intended meaning better (there will be no performance difference in recent world, as split is special casing for single character patterns anyway - see Java split String performances.
Feb
27
comment How can a private class method be tested in Scala?
See also can you test nested functions in scala?
Feb
26
comment Can I zip more than two lists together in Scala?
possible duplicate of Zip multiple sequences
Feb
26
awarded Supporter
Feb
25
awarded Informed
Feb
25
awarded Yearling
1 2 3 4 5