Merging symbols in common lisp

前端 未结 3 1883
南旧
南旧 2021-01-14 18:07

I want to insert a char into a list. However, I want to merge this char with the last symbol in the list. With appends and cons the result is always two different symbols.

3条回答
  •  -上瘾入骨i
    2021-01-14 18:43

    The answer to the question you ask is

    (defun concatenate-objects-to-symbol (&rest objects)
      (intern (apply #'concatenate 'string (mapcar #'princ-to-string objects))))
    (concatenate-objects 'a 'b) ==> ab
    

    Oh, if you want a list as the result:

    (defun xxxx (s1 s2) (list (concatenate-objects-to-symbol s1 s2)))
    

    However, I am pretty sure this is not the question you actually want to ask.

    Creating new symbols programmatically is not something beginners should be doing...

提交回复
热议问题