Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

4

(
    defun my-middle (lst)
    (
        cond
        ((null lst) nil)
        ((null (cdr lst)) nil)
        ((null (cdr (cdr lst))) nil)
        (
            (null (cdr (cdr (cdr lst))))
            (list (car (cdr lst)))
        )
        (
            t
            (
                append
                (list (car (cdr lst)))
                (my-middle (cdr lst))
            )
        )
    )
)

(
    defun my-last (lst)
    (
        cond
        ((null lst) nil)
        (
            (null (cdr lst))
            (car lst)
        )
        (
            t
            (my-last (cdr lst))
        )
    )
)

(
    defun f-l-swap (lst)
    (
        append
        (list (my-last lst))
        (my-middle lst)
        (list (car lst))
    )
)

(write (f-l-swap '((a d) f 10 w h)))

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.