subject

In each of the following questions predict the results first and then use the Lisp interpreter to check your answers:1. Write down the results of typing the following expressions in Lisp. (one line at a time).(list 'big 'cat 'sat)(cons 'the (list 'big 'cat 'sat))(list 'all (list 'good 'people) 'should (list 'go 'ahead))(cdr (car (cdr '(a (b c) d(cdadr '(a (b c) d))2. What will be the value of the last expression in each case?a. (setq a '(u v w)) (set (car (cdr a)) 'b) (cons v a)b. (setq A 'A) (setq B 'A) (list A B 'B)3. What will be the result of each of the following sets of s-expressions typed in Lisp environment?a. (defun double (x) (* 2 x)) (double 2.3)b. (defun times-square (x y) (* x y y)) (times-square 4 3)c. (defun TIMES-CUBE (X Y) (* X Y Y Y)) (defun CUBE-TIMES (X Y) (TIMES-CUBE Y X)) (CUBE-TIMES 3 2)Using an editor you may type the above functions in separate files with "lsp" or ".lisp" extension (you may use the editor which comes with Allegro Lisp - under file menu choose new option; write the code; save the program under the name double. lsp). And then load the program into the Allegro Lisp environment for execution (under file menu choose load option; write the name of the program double. lsp ). After loading the program you may execute any functions within that file using the listener window; CL-USER 1> (double 5) ;running the function double 104. Evaluate each of the following s-expressions:a. (atom '3)b. (floatp '(A B))c. (listp '(A B))d. (not (null 'nil))e. (not (atom '(A B)))f. (eq 'a 'a)g. (eq '(A B) (list 'A 'B))h. (eq 3 3.0)i. (equal 3 3.0)j. (eq 2.3 (+ 1.1 1.2))k. (and (atom '3) (listp '(A B)))5. Write two different s-expressions to access symbol C for each of the following lists. a. (A B C D E)b. ((A B C) (D E F))c. ((A B) (C D) (E F))d. (A (B C D) E F)6. Write a function DOT-PRODUCT that takes two lists, each list has three numbers (elements), and produces the dot product of the vectors that they represent. For example, -> (DOT-PRODUCT '(1.2 2.0 -0.2) '(0.0 2.3 5.0)) -> 3.6 The answer for this question can be found in file DOT-PRODUCT. LSP in the same directory. The key for designing a lisp function is using recursion.7. Write a function COUNT-NUMBER that counts the number of numbers that occur in a list. It should work like this: -> (COUNT-NUMBER '(A 2.3 B 5 4.53 C F)) -> 3 Hint: To determine whether s-expression is a number or not, use numberp function. The following examples show how numberp works:-> (numberp 5)-> T-> (numberp 5.5)-> T-> (numberp T)-> nil-> (numberp β€˜(A B))-> nil8. Write a function NEW-LIST that takes a number as its argument and constructs a list of that length containing all Ts. For example,-> (new-lit 5)-> (T T T T T)9. The Lisp function LENGTH counts the number of elements in the top level of a list. Write a function ALL-LENGTH of one argument that counts the number of atoms that occur in a list at all levels. Thus, the following lists will have the following ALL-LENGTHs. (A B C) => 3 ((A (B C) D (E F)) => 6 (NIL NIL (NIL NIL) NIL ) => 5Turn in your responses to these questions 6-9 in one single Lisp program file (.lsp or .lisp file)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:00
This is not a factor that you should use to determine the content of your presentation. your audience your goals your purpose your technology
Answers: 1
question
Computers and Technology, 22.06.2019 15:00
Hyperactive media sales has 10 windows 7 laptop computers used by sales-people in the organization. each laptop computer has several customized applications that are used during the sales process as well as customer relationship management software. all of the applications on the laptops are difficult to configure and have large data files. if all of the laptops have current hardware, what is the easiest way to install windows 10 on them?
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
Which of the following examples has four beats in each measure?
Answers: 2
question
Computers and Technology, 22.06.2019 17:40
Write a modular program (no classes yet, just from what you learned last year), that allows two players to play a game of tic-tac-toe. use a two-dimensional char array with 3 rows and 3 columns as the game board. each element of the array should be initialized with an asterisk (*). the program should display the initial board configuration and then start a loop that does the following: allow player 1 to select a location on the board for an x by entering a row and column number. then redisplay the board with an x replacing the * in the chosen location. if there is no winner yet and the board is not yet full, allow player 2 to select a location on the board for an o by entering a row and column number. then redisplay the board with an o replacing the * in the chosen location. the loop should continue until a player has won or a tie has occurred, then display a message indicating who won, or reporting that a tie occurred. player 1 wins when there are three xs in a row, a column, or a diagonal on the game board. player 2 wins when there are three ox in a row, a column, or a diagonal on the game board. a tie occurs when all of the locations on the board are full, but there is no winner. input validation: only allow legal moves to be entered. the row must be 1, 2, or 3. the column must be 1, 2 3. the (row, column) position entered must currently be empty (i.e., still have an asterisk in it).
Answers: 1
You know the right answer?
In each of the following questions predict the results first and then use the Lisp interpreter to ch...
Questions
Questions on the website: 13722361