[Haskell-cafe] Graphical graph reduction

Taral taralx at gmail.com
Mon Feb 25 16:19:10 EST 2008


On 2/24/08, dainichi at gmail.com <dainichi at gmail.com> wrote:
>  (define nth (lambda (n xs) (if (= n 0)(head xs)(nth (- n 1) (tail xs)))))

>  nth n (x:xs) = if n == 0 then x else nth (n-1) xs

I'm guessing it's some kind of lisp variant?

(define nth (lambda (n xs) (cond ((consp xs) (if (= n 0) (head xs)
(nth (- n 1) (tail xs)))) (t nil)))

-- 
Taral <taralx at gmail.com>
"Please let me know if there's any further trouble I can give you."
    -- Unknown


More information about the Haskell-Cafe mailing list