Question: In LISP Define a function my-last that takes two parameters, a symbol A and a list of symbols L, and returns the list starting where

In LISP

  1. Define a function my-last that takes two parameters, a symbol A and a list of symbols L, and returns the list starting where the last occurrence of symbol A is in L. It returns nil only if A is not in the list. Examples:
    • (my-last 'a '(a b c a b c a b c d e f g)) --> (a b c d e f g)
    • (my-last 'b '(a b c a b c a b c d e f g)) --> (b c d e f g)
    • (my-last 'c '(a b c a b c a b c d e f g)) --> (c d e f g)
    • (my-last 'g '(a b c a b c a b c d e f g)) --> (g)
    • (my-last 'h '(a b c a b c a b c d e f g)) --> nil

I only have these functions available.

    • defun
    • cond
    • cons
    • car
    • cdr
    • operators +, -, <, and >
    • null
    • eq
    • listp
    • atom
    • symbolp

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!