Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Seeing all this incorrect Scheme code hurts...

    (define (lastHalf L N)
      (if (= N 0) L); Base Case
      (if (or (= N 1) (< N 2))
          (cdr L)
          ;else
          (lastHalf (cdr L) (- N 1)))
          )

    Would be:

    (define (last-half L N)
      (if (= N 0)
         L
        (if (< N 2)
          (cdr L)
          (last-half (cdr L) (- N 1)))))


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: