Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a scheme lisp solution as follow: (define (transpose1 m) (if (null? (cdr

ID: 3773617 • Letter: I

Question

I have a scheme lisp solution as follow:

(define (transpose1 m)
(if (null? (cdr m))
    (map list (car m))
    (map cons (car m) (transpose1 (cdr m)))))
  
(define (transpose2 m)
(if (null? (cdar m))
    (list (map car m))
    (cons (map car m) (transpose2 (map cdr m)))))
  
(define (transpose3 m) (apply map list m))

and I converted to common lisp as follow:

(defun transpose1 (m)
(if (endp (cdr m))
    (map list (car m))
    (map cons (car m) (transpose1 (cdr m)))))
  
(defun transpose2 (m)
(if (endp (cdar m))
    (list (mapcar #'car m))
    (cons (mapcar #'car m) (transpose2 (mapcar #'cdr m)))))
  
(defun transpose3 (m) (apply mapcar list m))

but it gives me error: in TRANSPOSE1: Form too short, too few arguments: (MAP LIST (CAR M))

if i change map to mapcar then I get a different error: in TRANSPOSE1: LIST is neither declared nor bound

in TRANSPOSE1: CONS is neither declared nor bound

TRANSPOSE1: variable CONS has no value

how do I fix it

Explanation / Answer


(funcall ( transpose1 m) )

( funcall ( transpose2 m ) )

The lisp entity has to be set to constant literal data.
If the functions change the constant data, the common
lisp does not know about the impacts of these changes
or amendments

( funcall transpose3 m )

The ( MAP LIST (CAR M )) has to have the minimum number of arguments as
set forth in the function definition
While calling the function, the number of parameters
have to match the number of parameters mentioned in the
function definition

As long as the LISP functions are concerned, the following
guidelines are to be followed:

Syntax:
( defun functionName (list of parameters) "Character String data explaining as a documentation" Body or content of the function definition )

Example:
( defun sumNumbers (a b c d e f g h i j)
   ( + a b c d e f g h i j )
)

( write (sumNumbers 1 2 3 4 5 6 7 8 9 10))
upon running the above Lisp code would produce the output of
55

Lisp supports the list of parameters to be empty
as in the case of no argument functions

The functionality of the function can be provided in the purpose
of the function as a documentation

The statements, calculations, computations and other statements, and
expressions go inside the body of the Lisp function and as such there is
no limit on the number of executable statements that will go inside the
Lisp function

The return value can be of any type like String, integert, float, double etc
but usually the return statement is the last statement in the Lisp function

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote