Don’t have much anything to say, but you should check out Pandora’s radio.
Update
Wireless mice suck when they are low on charge…..
Don’t have much anything to say, but you should check out Pandora’s radio.
Update
Wireless mice suck when they are low on charge…..
is down or that the server is down is really overloaded. I hope the posts are all backed up.
|
V
[Update: Looks like its backup again!].
I’m really envious of people who always have somthing to write about on their blogs. Maybe inspiration will come to me…
I attended an interesting seminar today. A vice-predsident of the company that I work for, gave a talk about the historical background (from an engineering and technological point of view) about the area in imaging that my employer develops products for. There was an explosion of engineering , technological progress and invention in the second half of the nineteenth century. This progress came mainly from scientific academies that had been established in the two major powers of Europe, Britain and France, and then in Germany after unification. One major reason was that these academies started disseminating scientific knowledge via publishing and conferences , and scientists and engineers could collaborate using newer and efficient tools for communications, for example, the telegraph. This new knowledge allowed the rise of newer powers like the United States, Germany and Japan. It is said that after German unification, the rate of progress in Germany was so fast that Berlin completely supplanted Paris as the center of culture and science in Europe. Berlin was soon the leading center of Physics and Philosophy.
Fast forward into the future, to the last two decades of the twentieth century and we’re seeing history somewhat repeating itself. New tools of collaboration (email, internet, blogs, video, television) and knowledge dissemination and technological explosion (bio-tech nano-tech, etc), and new powers rising (China, India and Brazil) making use of the knowledge that is spreading around. This is an awesome thing! The only thing that we as a people should be worried about is that if we are finally repeating the good history, then are we also condemned to repeat the bad history that followed all that great progress in the nineteenth century.
A closure is a function that refers to a free lexical variable defined outside it, and that variable must persist as long as the function does.
Paul Graham in “Ansi Lisp”
By that definition, would’nt a pointer to member function that refers to a member variable of a object also be a closure, since its referring to a variable defined in the lexical scope of the class. Thinking about this, I googled it and looked about some comparisons of how closures are done. I realized that the code in the 2nd cut of my solution in this post was a a sort of closure. If you look at the definition of the source code of the nested class,
template<typename SequenceIterator>
struct find_max_sum_range_helper
{
public:
find_max_sum_range_helper
( typename SequenceIterator::value_type &max_so_far_
, typename SequenceIterator::value_type &max_ending_here_
, std::pair<SequenceIterator, SequenceIterator > &p_
, typename SequenceIterator ¤t_)
: max_so_far(max_so_far_)
, max_ending_here(max_ending_here_)
, p(p_)
, current(current_)
{ /* Do nothing else */}
void operator()(typename SequenceIterator::value_type val){
if(max_ending_here==0){
p.first = p.second = current;
}
max_ending_here =
std::max<typename SequenceIterator::value_type>(max_ending_here + val, 0);
if (max_ending_here > max_so_far){
max_so_far = max_ending_here;
p.second = current;
}
//increment the current operator;
++current;
}
private:
typename SequenceIterator::value_type &max_so_far;
typename SequenceIterator::value_type &max_ending_here;
typename std::pair<SequenceIterator, SequenceIterator> &p;
SequenceIterator ¤t;
};
find_max_range_helper refers to variables that are defined outside its lexical scope in find_max_range2, using C++ references as shown below.
...
typename SequenceIterator::value_type &max_so_far;
typename SequenceIterator::value_type &max_ending_here;
typename std::pair<SequenceIterator, SequenceIterator> &p;
SequenceIterator ¤t;
...
I mentioned in an earlier post that I may be having an interview soon. I was just brushing up some stuff that I wanted to look at, when getting slightly bored I decided to look at Google Interview Questions. Looking through some of these questions, really got me scared. I’m not sure if I’m going to get a chance to interview or not, but if I do that the interviewers are not as demanding as the ones that Google fields. Those are way out of my league. I came across an interesting site here called CarrerCup.com. This site created by Gale Lakmann has collected as many possible interview questions as possible. Some of the questions are kind of scary.