Trying to wrap my head around applicative order Y Combinators

October 28, 2009

… and my head hurts

IronPython and/or F#

March 11, 2008

I’ve been working with a large project that has a lot of unmanaged MFC and C++ code, and new managed code using C#, C++/CLI with a many third-party libraries written in unmanaged code. Because of the complexity of the code, and sheer number of projects (>50 at the last count), I’ve been debating on using some scripting language to prototype and test code. I know Python, so I’ve started off with that. Unfortunately, Visual Studio 2005 does not have a good integration with the IronPython console. I tried getting the add-in sample to integrate with Visual Studio, but after wasting a few hours decided to use it without intellisense.

F# on the other hand has pretty good integration wit a REPL console, compiler and interpreter. Although, I know some functional programming,  (doing some programming in Lisp, Haskell, and Boost.(Lambda|Bind|Spirit) in C++), F# seems to have an alien syntax. I’m pretty sure that after a few hours, I should get the hang of it. Probably, next weekend. Although its looking more and more likely that I’ll be at work this weekend again.

I do like this T-shirt though.


Brought to you via here.



I wish plain old C enums played nicely with CLS enums, or that I was smart enough to remember the nuances of how they differ.

Beware the Ides of March

March 15, 2007

My blogging spell was finally broken. I blogged sporadically for the last 4 weeks or so. I had promised myself that I was going to keep this going for the whole year, and keep the flow of useless thoughts I may have, flowing through my fingers. Unfortunately, like so many things in my life, that resolution finally fell on the way side, as I wandered off the road to Blogging Nirvana…..


BUT……. (drum roll)


I AM BACK!! and I am back with a vengeance. I have resolved to pick up my blogging banner and boldly march on this adventure again. The Ides of March seemed to be the perfect day. The day Julius Caeser died, so have I  resurrected this blog (again).


What have been doing lately?


 Very Busy at work. I thought of making this as an excuse for not updating my blog, but I decided against it. That has been the best part of the past couple of weeks. Being busy lets me focus more on my own code, rather than my bosses, who seem to have talent for their subordinates insane Are all bosses like this. Been writing a lot of ATL and COM code lately and that has been a lot of fun. Have been putting in 10 and 11 hours  at work every day or so. I still remember those horrible days back in 1999 and 2000 when I was first trying to learn OLE, COM and ATL. I just did’nt get it. Six years later, its the same stuff and it so seems obvious now. It’s really hard to believe that I was THAT dumb back then that I had to read everything twice just to make sure I could at least pretend I knew what I was talking about. My opinion of myself back then has sunk a little lower.


LISP programming has gone slower. Working my way of Chapter 4 of ANSI Common Lisp. Will post the solutions as soon as I get through them. In addition, I’ve started learning DirectX HLSL. I think it might come in useful in some image processing work that I’m doing right now.

ANSI Common Lisp Chapter 2 and 3 solutions

February 18, 2007

ANSI Common Lisp Chapter 2 solution
ANSI Common Lisp Chapter 3 solution

At some point in the future, I’ll be consoldiating my solutions to one page.

On to chapter 4.

Coding in Lisp

February 7, 2007

I was kind of bored so I started playing around with a little Lisp program I wrote. The CLisp compiler was throwing a strange compiler error on a (if… () () ) statement in a function that I had written. I stared at it for sometime, but I could’nt figure out what was wrong. It seemed legal code to me. About 15 minutes of bleary-eyed staring at the screen and (screen staring back at me), I realized that I had written an if statement as if I was writing C++. I don’n t know about others but sometimes its hard for me to switch between languages even if I know them well. I often mix-up syntaxes. This used to happen to me when I was learning C after having learnt Pascal. I would often start writing Pascal code when I should have been writing C. Its kind of funny to think about it right now, but its very frustrating when you’re actually coding and you have to deal with silly compilation problems.

About Lisp, Pandora, Central New York and Other things on my Mind

February 5, 2007

I’m working my way through Paul Graham’s Book Ansi Common Lisp. I’m feeling lazy right now ( I think that it being almost midnight has a lot to do with it), and I want the answers to some of the excercises. I went here, and looked up for some answers. Unfortunately, the writer did’nt post answers for chapter excercises that I was looking for. I guess I’ll have to figure this out the hard way.

Pandora’s automated selection of music has good and bad days. I spent Saturday morning and afternoon listening to it, while I randomly clicked around on the web, and I enjoyed song after song. Today, its just dismal. I dont get it. Maybe my preferences change between Saturday morning and Monday evening.

Central New York’s weather sucks big-time today and will remain crummy until Friday, when the lake-effect snow and arctive wind finally subside. We’ve had a uncharacteristically warm December, and I had almost dared to hope that the warm spell may have just last. It was wishful thinking. Winter came back roaring back. Looking at the weather outside, it would be hard to believe that global warming is occuring because it sure does’nt look like it. Its no wonder there are so many environmental skeptics out there, when they have to go through these kinds of winters. I’m bracing myself for about a foot of snow this winter.

Other things on my mind? Tax Season. I made a New Year Resolution that I would get my taxes done as soon as I got my W-2 forms. I got mine about 2 weeks ago. Procrastination will be the end of me. I found an interesting tax tip today. I need to confirm this but an extra $30 is’nt bad.

Closures vs. Objects

January 23, 2007

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
            ( typename SequenceIterator::value_type &max_so_far_
            , typename SequenceIterator::value_type &max_ending_here_
            , std::pair<SequenceIterator, SequenceIterator > &p_
            , typename SequenceIterator &current_)
            : 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){
                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;

        typename SequenceIterator::value_type &max_so_far;
        typename SequenceIterator::value_type &max_ending_here;
        typename std::pair<SequenceIterator, SequenceIterator> &p;
        SequenceIterator &current;

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 &current;