Using cons using `list` or` append`

Is there any way by which conscan be implemented in Common LISP using the list, append, first, restand etc.

In the following code

(defun my_list (&rest arguments)
   `(,@arguments) ; Line 1
)

What does full line 1 mean?

+3
source share
4 answers

First question: No, because it consis the building block for listand append, and not vice versa. It is like trying to build a brick from a house.

Second question: the backquote syntax is explained in the CLHS ( http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_2-4-6.html ).

Stylistic comments:

  • It is spelled "Common Lisp".

  • , : my-list.

  • . :

    (defun my-list (&rest arguments)
      `(,@arguments)) ; Line 1
    
  • backquote . :

    (defun my-list (&rest arguments)
      arguments)
    
+6

, cons list append, :

(defun cons (car cdr) (append (list car) cdr))
+1

:
:,
if my_symbol = 1
`(my_symbol 2 3) = (my_symbol 2 3), ::

`(,my_symbol 2 3) = (1 2 3)

The, `statement

@( , )

`(,@('a 'b 'c) ('d 'e 'f)) = ('a 'b 'c ('d 'e 'f) )

`(,@('a 'b 'c) ,@('d 'e 'f) ) = ('a 'b 'c 'd 'e 'f)

, . , 1 .

0

?

(defun cons (a b) '(a . b))

, ...

(defun cons (a b) (first (list '(a . b))))
-1

Source: https://habr.com/ru/post/1775654/


All Articles