Splitting the dark side ...Comments
Display comments as
(Linear | Threaded)
CL:
(defun as-unordered-list (input) (format t "~%~{~A~%~}~%" (split-sequence:split-sequence #| input :remove-empty-subseqs t)))
I haven't looked at split-sequence yet, but have recently also done some obfuscation of my source code with the more elaborated features of format. While that's surely useful, I need to look them up each time I stumble over them in code (i.e., I'm not doing enough programming in CL to remember the details of the "unusual" features of CL's format).
Um, what's wrong with selecting the relevant lines and then
:s/\v(\d+)\. (.*)/⋖li id="\1"⋗\2⋖\/li⋗ Yes, this is Vim syntax, but I'm sure the Emacs syntax is just as short. Or you can record a keyboard macro on the fly, as you like. I do this kind of text processing every day, and I don't see why you would need to write a Perl/Lisp/Ruby script, except as an exercise. Or maybe I fail to see your point…
There is nothing wrong with a manual replace-regex or
keyboard macros in general apart from two things: I'm probably going to need this substitution again, some time from now. And when I come back in two months to do the same thing again, I like to see and understand what exactly I've been doing. For this documentation part of the task, I find a plain function definition much more suitable.
The CL example is wrong. The regex string should have been "\|".
Add Comment
|
QuicksearchBlog AdministrationHolger's little blog worldKategorienCalendar
1on.de |
|||||||||||||||||||||||||||||||||||||||||||||||||
Some time ago, I was looking at splitting some text with Elisp, Perl, Ruby and Common Lisp. Yesterday, when I again had to do quite the same thing, it occurred to me that the Common Lisp solution was unnecessary complex/long. I'm not a Perl guru, but I be
Tracked: Nov 09, 09:50