About ericlippert

http://ericlippert.com

Forest path

This is a path through a dimly lit forest, curving from south to east. A large tree with low branches stands by the edge of the path. On the ground is a pile of leaves.

> count the leaves

69,105.

> climb the tree

Continue reading

West of house

You are standing in an open field west of a white house, with a boarded front door. You could circle the house to the north or south. There is a small mailbox here.

> open the mailbox

Opening the small mailbox reveals a leaflet.

> read the leaflet

[Taken]

“WELCOME TO ZORK, a game of adventure, danger, and low cunning. No computer should be without one!”


Continue reading

Space oddity

Many years ago I awoke in the dead of night in a cold sweat, with the certain knowledge that a close relative had suddenly died. […] In fact, the relative is alive and well […]. However, suppose the relative had in fact died that night. You would have had a difficult time convincing me that it was merely coincidence. But it is easy to calculate that if each American has such a premonitory experience a few times in his lifetime, the actuarial statistics alone will produce a few apparent precognitive events somewhere in America each year. We can calculate that this must occur fairly frequently, but to the rare person who dreams of disaster, followed rapidly by its realization, it is uncanny and awesome. Such a coincidence must happen to someone every few months, but those who experience a correct precognition understandably resist its explanation by coincidence.

After my experience I did not write a letter to an institute of parapsychology relating a compelling predictive dream which was not borne out by reality. That is not a memorable letter. But had the death I dreamt actually occurred, such a letter would have been marked down as evidence for precognition. The hits are recorded, the misses are not.

Thus Carl Sagan in his 1979 book Broca’s Brain. Continue reading

Functional programming for beginners

Happy New Year everyone; I hope you had a pleasant and relaxing festive holiday season. I sure did.

I’m starting the new year off by giving a short — an hour long or so — talk on how you can use ideas from functional programming languages in C#. It will broadcast this coming Wednesday, the 13th of January, at 10AM Pacific, 1PM Eastern.

The talk will be aimed straight at beginners who have some experience with OOP style in C# but no experience with functional languages. I’ll cover ways to avoid mutating variables and data structures, passing functions as data, how LINQ is functional, and some speculation on future features for C# 7.

There may also be funny pictures downloaded from the internet.

Probably it will be too basic for the majority of readers of this blog, but perhaps you have a friend or colleague interested in this topic.

Thanks once again to the nice people at InformIT who are sponsoring this talk. You can get all the details at their page:

http://www.informit.com/promotions/webcast-a-beginners-guide-to-functional-programming-141067

In related news, I am putting together what will be a very, very long indeed series of blog articles on functional programming, but not in C#. Comme c’est bizarre!

Foreshadowing: your sign of a quality blog. I’ll start posting… soon.

The dedoublifier, part four

I said last time that binary-searching the rationals (WOLOG between zero and one) for a particular fraction that is very close to a given double does not really work, because we end up with only fractions that have powers of two in the denominators. We already know what fraction with a power of two in the denominator is closest to our given double; itself!

But there is a way to binary-search the rationals between zero and one, as it turns out. Before we get into it, a quick refresher on how binary search works:
Continue reading