Archive for April, 2008|Monthly archive page

Smooching

This has been something that’s come up a lot with my friends in the DSG. Do you kiss on the first date? I’m a strong member of the “no” camp. One of my female friends is a member of the “yes”* camp. We have discussed this a couple of times and I think we just agree to disagre.

Has this cost me in the past? Perhaps, but if it has well I think that’s a little lame on that other person’s part.

But why the “no” camp you ask? Well, frankly, when I’m on a first date with someone, especially if I’ve just met them, I don’t know them and they don’t know me. Yeah, kissing is fun, but you can’t take that back. So, I want to get to know them a little before we add that to the mix.

* only if the date is going really well.

living for the moment

I went to see Ellis a show a little while ago at Club Passim and she had a great quote:

“I’m so looking forward to the present moment!”

wow! That’s a viewpoint I’m going to work on adopting!

Craig

German Rap Rules

What is it about German rap that is just awesome? I find it better than rap in any other language I know of. Perhaps because I’m listening to the incomparable Fanta Vier. The language always, it seems, rhymes with itself. The rhythm is awesome. The flow of the language is perfect. French rap always seems to blur into each other, but German with it’s gutteral language is always clear in rap.

I wonder what Italian rap is like. I love the sound of the Italian language…

I Hate Credit Card Offers

A while back I did a great thing, I opted out of free credit card offers. They clogged up my mail box, I had to shred them–a general hindrance of fun in my life. Then I opted out of receiving credit card offers via mail and after 4 weeks the junk mail I received dropped dramatically. I highly recommend it. Do it:

https://www.optoutprescreen.com/?rf=t

tail recursion is cool

During an interview I was asked to write in Lisp code to reverse a list. So I naively wrote the following:

(defun reverse ( l )
  (cond
    ((null l ) null )
    (t
      ((append (car l) (reverse (cdr l)))))
  )
)

The interviewer wisely asked if that could be done better. Hmm, I thought, it’s O(n)..but no, it’s actually O(n^2) because the append has to traverse the list that’s under construction. OK so how to do it without the append. I struggled a little bit because I always wind up with a dotted pair, screwing up the proper list aspects. Remember that if you cons two atoms together you get a dotted pair. The code “(cons 1 2)” will yield “(1.2)”. Instead you need to have the null and use multiple cons blocks, “(cons 1 (cons 2 null))”.I struggled with this a little bit trying to get the recursive and lisp code in my head (“Fascinating!“). So the interviewer, Jeff, suggested I write it iteratively in C-esque code. I thought about that for a while and backed off on that writing instead the desired cons calls that I needed to generate. If I had the list (1 2 3 4) I would need the following reversed cons calls, (cons 4 (cons 3 (cons 2 (cons 1 null)))). OK with that in mind I wrote the following which is a combination of C with Lisp data structures:

List reverse(List l) {
  tmp = null
  while ( l != null ) {
    tmp = cons(car(l), tmp) // merge first element onto beginning of tmp list
    l = cdr(l)
  }
  return tmp
}

OK. That works now, Jeff asked, write that recursively in Lisp. Well, obviously I need another variable:

(defun reverse (l tmp)
  (cond
    ((null l) tmp)
    (t
     (reverse (cdr l) (cons (car l) tmp)))))

The initial call is: (reverse ‘(1 2 3 4) null)Create a wrapper function if you don’t want to expose the tmp variable to the caller. Very interesting!