Anonymous user
String prepend: Difference between revisions
Emacs Lisp: Actually solve the task
(Added solution for Action!) |
(Emacs Lisp: Actually solve the task) |
||
Line 655:
=={{header|Emacs Lisp}}==
While strings in Emacs Lisp are mutable, they're fixed size. Therefore the <code>concat</code> function creates a new string and the existing string must be referenced twice:
<lang Lisp>(defvar str "bar")
(setq str (concat
str ;=> "foobar"</lang>
This can be hidden by using a macro such as <code>cl-callf2</code> which expands into the above code:
{{libheader|cl-lib}}
<lang Lisp>(require 'cl-lib)
(
(
str ;=> "foobar"</lang>
(insert str)▼
Buffers can be thought of as expandable strings:
<lang Lisp>(let ((buf (get-buffer-create "*foo*")))
(with-current-buffer buf
(insert "bar"))
(with-current-buffer buf
(goto-char (point-min))
(buffer-string)))
;; => "foobar"</lang>
=={{header|Erlang}}==
|