### Woo hoo!

Posted:

**Wed Oct 14, 2015 9:30 pm**Programming n00b, I was solving the book question, "Write a function FIRSTZERO that takes 3 numbers as input and returns a word (one of "first," "second," or "none") indicating where the first zero appears."

So I wrote (defun firstzero (x y z) (if (= x 0) 'first (if (= y 0) 'second (if (= z 0) 'third 'none)))) All done in 92 characters and it works.

Then I went to solutions to check if I got it right. Wow, the author did it with cond instead? (defun firstzero (x) (cond ((zerop (first x)) 'first) ((zerop (second x)) 'second) ((zerop (third x)) 'third) (t 'none))) 121 whopping characters and the numbers must be in list form too!

Did I just outcode the book? I'll be hovering above ground for the rest of the day with little pink trumpeting aureolae circles from happiness. If this was by design to make me feel great, thanks. One is proudest about things one is a n00b at.

(Tomorrow once I'm back on solid ground, feel free to point out how this could be far shorter with a macro. Macros are still 300 pages away.)

So I wrote (defun firstzero (x y z) (if (= x 0) 'first (if (= y 0) 'second (if (= z 0) 'third 'none)))) All done in 92 characters and it works.

Then I went to solutions to check if I got it right. Wow, the author did it with cond instead? (defun firstzero (x) (cond ((zerop (first x)) 'first) ((zerop (second x)) 'second) ((zerop (third x)) 'third) (t 'none))) 121 whopping characters and the numbers must be in list form too!

Did I just outcode the book? I'll be hovering above ground for the rest of the day with little pink trumpeting aureolae circles from happiness. If this was by design to make me feel great, thanks. One is proudest about things one is a n00b at.

(Tomorrow once I'm back on solid ground, feel free to point out how this could be far shorter with a macro. Macros are still 300 pages away.)