• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

more scheme - lists

I need to define a procedure 'last' that returns the list that contains only the last element of a given nonempty list
1 Solution
(define (length x) (if (null? x) 0 (+ 1 (length (cdr x)))))

(define (last l)
        (if (null? l)
            (if (= 1 (length l)) l (last (cdr l)))))

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now