Hot answers tagged

6

we already had well-established mechanisms for manipulating collections in several other languages [...]. Since the creators of java decided that java collection streams are worthy of including in Java 8, they must think that java collection streams offer something which the (arguably simpler) pre-existing mechanisms do not." I think you're starting from a ...


5

when I create a val two = new Succ(2) why would I set the two.predecessor = 2 when 2's predecessor is actually 1? You can't call new Succ(2), as Succ needs to have an object of type Nat as argument, and the literal 2 is not of type Nat. Succ is defined as the natural number succeeding (or following) the Nat object given as its argument. With the code ...


5

My question is ... how I can map db tables in excel files to give it to users instantly, when they want to download a table? Simple answer: you can't, unless you have the files prepared in advance. .xlsx files are ZIP archives which can't easily be produced in a streaming fashion, so to give one to the user you will need to create it from the database ...


4

As this wonderful bloomfilter tutorial by llimllib will show you, when you test an element you have to recalculate its hash. This will tell you what bits it sets in the bloom filter. If your bloomfilter is outside of system ram but is on a storage device that still has random access you could pull only the pertinent bytes from storage and test them against ...


3

The encoding shown here is based on the Peano Axioms for natural numbers: Z ∈ ℕ. (Existence of zero.) ∀x ∈ ℕ: x = x. (Reflexivity of equality.) ∀x, y ∈ ℕ: x = y ⇒ y = x. (Symmetry of equality.) ∀x, y, z ∈ ℕ: x = y ∧ y = z ⇒ x = z. (Transitivity of equality.) ∀a, b: b ∈ ℕ ∧ a = b ⇒ a ∈ ℕ. (Closure under equality.) ∀n ∈ ℕ: S(n) ∈ ℕ. (Closure under S.) ∀...


2

Well, this is like asking what Gmail offers that Outlook.com does not. It's not technical No, really, I do believe that there is no technical reason behind this. What I am suspecting is that you are confusing the meaning of simplicity, although I am not certain about this. Since the creators of java decided that java collection streams are worthy of ...


2

Databases have been designed to be accessed from multiple threads for a long time. Try googling about how to use transactions in databases that should help you on how to ensure consistency in the face of concurent read and write. Also scince you are using mysql, ensure that you are not using the older myisam backend, it has missing support for a lot of ...


2

I wouldn't consider this to be a violation of the open-closed principle: because the trait is sealed, the relevant entity isn't just Person, but Person together with its implementations, and isn't open for extension either way!


1

Scala does have structural types, but they incur a runtime penalty: def lookupPersonAge(person: {val id: Int}): Int There's also the typeclass route, but it requires more boilerplate to define the instances: def lookupPersonAge[A](person: A)(implicit i: HasId[A]): Int Another nice option in some situations is to make Named the trait: trait Named { ...


1

I noted above in a comment that 2GB seems like a obsolete JVM limit but I'm going to answer here assuming that this is a real hard limit that you must adhere to. After thinking about this for a while and playing around with a spreadsheet for various options, it occurred to me that you could avoid your specific issue by scaling out to multiple VMs. To start ...


Only top voted, non community-wiki answers of a minimum length are eligible