r/programming • • May 08 '15

Five programming problems every Software Engineer should be able to solve in less than 1 hour

https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
2.5k Upvotes

2.1k comments sorted by

View all comments

11

u/thebhgg May 08 '15
(defun prob-1a (lst)
  (reduce #'+ lst))

Crap, it's not a for loop.

(defun prob-1b (lst)
  (apply #'+ lst))

Crap! It's not a while loop!

(defun prob-1c (lst)
  (let ((val 0))
    (dolist (x lst val) (incf val x))))

CRAP!!

(defun prob-1d (lst)
  (if lst
      (+ (car lst) 
	     (prob-1d (cdr lst)))
      0))    

It figures: recursion is the only natural way.

→ More replies (6)