News for hackers. Stuff that matters.
Re:A bad citizen in Javaland (2006) by danieldk on Thursday December 03, 2015 @06:44AM (#10669084)
You can't change the chair because it's all immutable, so you create a new chair along with a new universe and build a new car with the new chair.

No, if you read Okasaki, you knew you only have to reconstruct the part of the universe (up to its origin) that refers (directly or indirectly) to the seat ;).

In fact, you can safely have two universes with different seats, where most of the universes is shared.

Re:A bad citizen in Javaland (2006) by RyanZAG on Thursday December 03, 2015 @06:50AM (#10669105)
Oh that makes for a funny part of the ending too then.

While going about your work, you suddenly disappear along with your universe and everything in it. Someone somewhere in the world drank a cup of coffee, which means that he now has an empty cup instead of a full cup. A new universe had to be created with the full cup replaced, and unfortunately your universe had to be thrown away. You continue life as a clone in a new universe with an empty coffee cup somewhere in Nebraska.

Why did this happen? Someone picked a copy-on-write map implementation because it had a slightly faster O(logN) delete behavior and unfortunately the re-use function of the map wasn't implemented yet because the author has gone on to do a series on the use of monads in baking the ultimate croissant.

Re:A bad citizen in Javaland (2006) by Someone on Thursday December 03, 2015 @09:05AM (#10669571)
"Someone somewhere in the world drank a cup of coffee, which means that he now has an empty cup instead of a full cup"

That cannot happen in an immutable world. To fill an empty cup, you cons a cup and its contents. To get an empty cup again, you take the car of the cons. The full cup will only get garbage collected if you do not reference it anymore.

Re:A bad citizen in Javaland (2006) by catnaroek on Thursday December 03, 2015 @04:52PM (#10672954)
> To fill an empty cup, you cons a cup and its contents.

That simply has the wrong type in mathematically civilized languages like Standard ML or Haskell.

> The full cup will only get garbage collected if you do not reference it anymore.

This is orthogonal to functional programming. You can avoid the need for a garbage collector with substructural types.

Re:A bad citizen in Javaland (2006) by TeMPOraL on Thursday December 03, 2015 @06:55AM (#10669119)
Hence, Many World Interpretation of quantum mechanics.
Re:A bad citizen in Javaland (2006) by koenigdavidmj on Thursday December 03, 2015 @08:17AM (#10669371)
Sorting in O(n) time:

1. Apply a quantum permutation to your list.

2. Check if it's sorted.

3. If not, destroy the universe.

Re:A bad citizen in Javaland (2006) by evanpw on Thursday December 03, 2015 @10:13AM (#10669933)
Related (amazing) paper by Scott Aaronson: "NP-complete Problems and Physical Reality" (http://arxiv.org/abs/quant-ph/0502072). He proposes "anthropic computing" as a way of solving NP-complete problems in polynomial time: guess an answer, then kill yourself if the answer is wrong.
Re:A bad citizen in Javaland (2006) by dtech on Thursday December 03, 2015 @11:57AM (#10670658)
It would be very eerie if suddenly all the guesses started being right.
Re:A bad citizen in Javaland (2006) by kragen on Thursday December 03, 2015 @10:25AM (#10670022)
I am worried that someone will actually try this sometime and it will turn out not to work, either because MWI is wrong or because the destruction of the universe was incomplete — for example, collapsing the false vacuum would merely change the state of the things in the universe, not destroy the universe per se.

Fortunately, we don't have any currently promising avenues for nucleating a true vacuum or anything like that, so this algorithm is purely theoretical.

For now.

Re:A bad citizen in Javaland (2006) by arethuza on Thursday December 03, 2015 @08:40AM (#10669466)
That made me think of Greg Egan's Quarantine:

https://en.wikipedia.org/wiki/Quarantine_%28Greg_Egan_novel%...

Re:A bad citizen in Javaland (2006) by moron4hire on Thursday December 03, 2015 @08:47AM (#10669494)
Best-case runtime = 1. Worst-case = infinity.
Re:A bad citizen in Javaland (2006) by AndrewOMartin on Thursday December 03, 2015 @09:37AM (#10669745)
I think the joke is that in all cases but the best-case, you won't be around to observe it, this becomes practical once you can create a universe for every permutation and destroy all but the universe which notifies you that it's the best-case.

In all good text books this is left as an exercise for the reader.

Re:A bad citizen in Javaland (2006) by AnimalMuppet on Thursday December 03, 2015 @12:38PM (#10671041)
In a really good text book, this is left as an exercise that the reader won't do.
Re:A bad citizen in Javaland (2006) by danieldk on Thursday December 03, 2015 @09:38AM (#10669748)
No, checking whether a list is sorted is O(n) ;).

Bogosort is O(n) in the best case and O(inf) in the worst case).

Re:A bad citizen in Javaland (2006) by lisivka on Thursday December 03, 2015 @10:57AM (#10670257)
Optimize out the check, so it will be O(1) in some cases. ;)
Re:A bad citizen in Javaland (2006) by frozenport on Thursday December 03, 2015 @10:59AM (#10670274)
The convergence of this method depends on the underlying distribution for your random process. It could be O(never).
Re:A bad citizen in Javaland (2006) by jerf on Thursday December 03, 2015 @01:26PM (#10671495)
As Scott Aaronson points out, the easy solution to this is that you add a slight quantum chance that the algorithm will yield "Reject". As long as that chance is non-zero, but greatly smaller than the probability of any particular successful permutation, you will survive in the universe that says "Reject".
Re:A bad citizen in Javaland (2006) by theseoafs on Thursday December 03, 2015 @02:46PM (#10672040)
This sounds like a joke but this is exactly the proof that sorting is in NP.
Re:A bad citizen in Javaland (2006) by andrepd on Thursday December 03, 2015 @11:24AM (#10670443)
What is a quantum permutation?
Re:A bad citizen in Javaland (2006) by ninjakeyboard on Thursday December 03, 2015 @09:16AM (#10669630)
A new chair isn't created - the legs, seat, and back of the old chair are re-used with new screws.

If you want to replace a leg, you still need to disassemble the chair and reassemble it with new screws.

Re:A bad citizen in Javaland (2006) by platz on Thursday December 03, 2015 @10:52AM (#10670221)
I've never considered the many-worlds interpretation of quantum physics under the light of persistent data structures.. very interesting!