Question: Coding must be done in the Lisp Language! 2. Define a recursive function in the manner (defun permute (input-list) .. .) which outputs a list


Coding must be done in the Lisp Language!
2. Define a recursive function in the manner (defun permute (input-list) .. .) which outputs a list of all permutations of a (short!) 'input-list without duplications. If 'input-list' is not a proper list, return it unchanged. IF THERE ARE MORE THAN 5 ELEMENTS IN THE INPUT -LIST PRINT OUT AN ERROR MESSAGE, and return the input unchanged. Example:s (permute 'a) A permute '(a . b)(A . B) (permute ) a ist* containing the only permutationh (permute (a b C))-> ((a b c) (a C b) (b a c) (c a b) (b c a) (c b a)) (permute (a b a)) --> ((a b a) (a a b) (b a a)) ( permute( (a b) (cd) (a b) )-> ((a b) c d) (a b)) ((a b) (a b) (c d)) ((c d) (a b) (a b))) . . , (permute (a b cdef)) --> **ERROR: Th (A B C D EF) e input to permute' must not have more than 5 elements! N.B: Do NOT TRY To ACTUALLY PERMUTE MORE WISH TO BURN UP COMPUTER CYCLES AND MEMORY FOR NO GOOD REASON!! THAN 5 ELEMENTS! WE DO NOT NOTE: You can use the Common Lisp function 'remove -duplicates' do it in the manner (remove -duplicates my-list :test 'eq otherwise things Common Lisp distinguishes, eq, eql, and these differ; e.g., (equal (a b) '(a b)) --> T, whereas (eg , (a b) . (a b)) ==> NIL. uaU like (a b), (a b) wili be deemed unequal! equal. Read up on how 2. Define a recursive function in the manner (defun permute (input-list) .. .) which outputs a list of all permutations of a (short!) 'input-list without duplications. If 'input-list' is not a proper list, return it unchanged. IF THERE ARE MORE THAN 5 ELEMENTS IN THE INPUT -LIST PRINT OUT AN ERROR MESSAGE, and return the input unchanged. Example:s (permute 'a) A permute '(a . b)(A . B) (permute ) a ist* containing the only permutationh (permute (a b C))-> ((a b c) (a C b) (b a c) (c a b) (b c a) (c b a)) (permute (a b a)) --> ((a b a) (a a b) (b a a)) ( permute( (a b) (cd) (a b) )-> ((a b) c d) (a b)) ((a b) (a b) (c d)) ((c d) (a b) (a b))) . . , (permute (a b cdef)) --> **ERROR: Th (A B C D EF) e input to permute' must not have more than 5 elements! N.B: Do NOT TRY To ACTUALLY PERMUTE MORE WISH TO BURN UP COMPUTER CYCLES AND MEMORY FOR NO GOOD REASON!! THAN 5 ELEMENTS! WE DO NOT NOTE: You can use the Common Lisp function 'remove -duplicates' do it in the manner (remove -duplicates my-list :test 'eq otherwise things Common Lisp distinguishes, eq, eql, and these differ; e.g., (equal (a b) '(a b)) --> T, whereas (eg , (a b) . (a b)) ==> NIL. uaU like (a b), (a b) wili be deemed unequal! equal. Read up on how
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
