Tuesday, 1 October 2013

a problem about Inequality zoom

a problem about Inequality zoom


I came across this inequality. Can anyone help me?

Monday, 30 September 2013

Decomposition of exponential random variable – math.stackexchange.com

Decomposition of exponential random variable – math.stackexchange.com

I know that sum of independent Exponential random variables follows Gamma
distribution. But Is it possible to decompose exponential random variate
into independent and identically gamma random ...

How does one prove that $6$ divides ${(3n)!}/{(n!)^3}$=?iso-8859-1?Q?=3F_=96_math.stackexchange.com?=

How does one prove that $6$ divides ${(3n)!}/{(n!)^3}$? –
math.stackexchange.com

How does one prove that $6$ divides the multinomial coefficient
$\displaystyle \frac{(3n)!}{\;(n!)^3}$?

Where to check if record exists?

Where to check if record exists?

Just a coding design related question. Where does it make more sense to
check for a records existence before inserting it into the database. The
service layer or repository?

Xap file in windows phone app

Xap file in windows phone app

I have 2 Xap file in "MyApplication -> Bin -> Release" folder
1)MyHelloWorldSampleApp.xap(3,820KB)
2)MyHelloWorldSampleApp_Release_AnyCPU.xap(4,631KB)
Anybody can explain about whats the difference between this two.
Thank you.

Sunday, 29 September 2013

Scala: Type mismatch, returns BlockList[Any] instead of BlockList[R]

Scala: Type mismatch, returns BlockList[Any] instead of BlockList[R]

Just to get more experience with Scala, and as an experiment, I'm
implementing a class that has a List-like API, but is implemented as a
list of IndexedSeq with an index to the first element; tail just returns a
copy with the index incremented, and prepending Arrays is O(1), while
appending Arrays is O(m), m = length of list <= number of elements.
I'm running into problems with my function return types. Pretty much every
method has the type parameters [R >: T : ClassManifest, A <: R :
ClassManifest], T being the type parameter of BlockList. Sometimes these
methods just return others, but in those situations I get an error from
Eclipse saying that it was looking for type BlockList[R] but found type
BlockList[Any]. Shouldn't R be the lowest common super type of both T and
A? In which case, the second method call should also return BlockList[R],
right? What am I not getting? I reflect ClassManifest a lot to overcome
the problems of type erasure, but I don't know if it's still a problem.
The errors are from the definitions of |: and :|. I also get an error from
new Build[R](block, next :| blk, index), saying that none of the
constructors can be applied to (IndexedSeq[T], BlockList[Any], Int).
import collection.immutable.List
import reflect.ClassManifest
import annotation.tailrec
sealed abstract
class BlockList [+T] extends Seq[T] with Product {
...
}
class Build [T: ClassManifest](
private val block: IndexedSeq[T],
private val next: BlockList[T] = EmptyBlock,
private val index: Int = 0
) extends BlockList[T] {
require(!block.isEmpty && index >= 0 && index < block.length)
def this (blk: Array[T], nxt: BlockList[T] = EmptyBlock, idx: Int = 0) {
this(blk toIndexedSeq, nxt, idx)
}
override def |: [R >: T : ClassManifest, A <: R] (x: A): BlockList[R] =
Array[R](x) |: this
override def |: [R >: T : ClassManifest, A <: R : ClassManifest]
(blk: IndexedSeq[A]): BlockList[R] =
if (blk isEmpty) this
else new Build[R](blk, this)
override def :| [R >: T : ClassManifest, A <: R] (x: A): BlockList[R] =
this :| Array[R](x)
override def :| [R >: T : ClassManifest, A <: R : ClassManifest]
(blk: IndexedSeq[A]): BlockList[R] =
if (blk isEmpty) this
else new Build[R](block, next :| blk, index)
override def :|: [R >: T : ClassManifest, A <: R : ClassManifest]
(prefix: BlockList[A]): BlockList[R] =
prefix match {
case prefix: Build[R] => prefix.block |: (prefix.next :|: this)
case EmptyBlock => this
}
override def apply (n: Int): T =
if (n < 0 || n >= length) throw new IndexOutOfBoundsException(
"Cannot get element "+n+"; not within bounds."
)
else if (n < block.length - index) block(n + index)
else next(n - block.length + index)
override lazy val length: Int = (block length) - index + (next length)
}
object EmptyBlock extends BlockList[Nothing] {
...
}

using fstream style in php

using fstream style in php

I have been using file streams with c++ for years and can load character
strings from a file like this:
char a[30],b[30],c[30];
ofstream fp;
fp.open("file.txt");
fp<<a<<b<<c;
Is there a way to read strings from a file in PHP in the same fashion
without reading a whole line or file?