freenode/#lisp - IRC Chatlog
Search
20:26:42
aeth
I guess if you want it to match in style you would replace CAR with FIRSt and CDDR with (rest (rest ...))
20:27:35
aeth
I personally tend to use the CXRs for syntax where DESTRUCTURING-BIND isn't desirable (it usually is, since errors are good, but in this case, it would error instead of returning NIL)
20:39:35
jackdaniel
yes, it is (quote foo) ; for my defense, I've added a disclaimer that it is late :)
21:04:04
aeth
my bad, it's (defun quoted-p (form) (and (listp form) (eql (car form) 'quote) (cdr form) (endp (cddr form))))
21:04:42
aeth
But you have to try really hard to actually get that edge case because e.g. (quote) is an error
6:40:40
beach
Well, it is hard to tell from your example what it is that you need exactly. I assume some-name is a variable?
6:41:35
sda
I'm trying to convert the string "!name: some-name-could-be-anything" to "<h3>Name:</h3> some-name-could-be-anything<br>"
6:42:04
flip214
sda: either use CL-PPCRE, or write a parser (eg. via ESRAP), or use CL:READ with a custom readtable and a few reader macros.
6:42:37
flip214
Depending on how much time you've spent with regular expressions I'd suggest on of the first two ways.
6:43:22
Nilby
You'd have to specify what the syntax for "!name: some-name" is a little more precicely. For example can "name" have a #\space or a #\: in it?
6:43:35
flip214
sda: do you have some regular grammer that you need? ! => h3, !! => h2, !!! => h1 or so?
6:47:46
Nilby
Here's a free and imperfect regex for you: (ppcre:scan "!([^: ]+):\\s*(.*)$" "!name: some-name")
6:50:22
Nilby
But regexp can have some notorious troubles, so I find it's best to just manually parse out a simple string.
6:50:58
flip214
sda: for HTML generation I generally suggest to use CL-WHO, but if it's only that one line you needn't bother
6:56:35
flip214
well, (multiple-value-bind (full matches) (cl-ppcre:scan-to-strings "^!(.*?): *(.*)" input) ....) will give you the two parts you're interested in in (aref matches 0) and (... 1)
6:57:36
beach
Who was it that said that attempting to solve a problem using regular expressions results in two problems.
7:39:00
flip214
beach: yeah, there's a saying. still, for small, quick text manipulation, RE are as dense as it gets (in both senses of the word ;)
7:41:51
beach
Wow, chapter 4 of Land of Lisp is entitled "making decisions with conditions", but in fact it is about conditionALs. Also, on page 51 the author encourages the use of a list variable as a Boolean, and also reverses the IF branches compared to a proof by induction.
7:45:25
beach
Also on page 51, the author claims that the expressions (), '(), nil, and 'nil are "equivalent" without stating the context that would make them so.
7:46:09
beach
No wonder so many people who come here have troubles with this stuff. We must start by making them forget lots of stuff they have "learned" from this book.
7:48:35
beach
The entire thing is written in a very sloppy way. I wonder who were the editors in charge of catching stuff like that.
7:55:17
Nilby
I don't trust what I read, but I think the spirit and enthusiasm expressed in that book is good. If one can be mostly correct and fun, that's an amazing achievement.
8:00:09
beach
Also, there is a large number of people, me included, who get so distracted by inconsistencies like this, that they have a hard time appreciating the message at all.
8:00:39
edgar-rft
WhenI learned Lisp in the 1990s every second tutorial still used plain lists as conditionals and I agree with beach that this caused me lots of confusion.
8:00:56
beach
A large part of technical writing is to avoid distracting the reader with inconsistencies like that.
8:01:24
Nilby
I basically agree. Which I why I learned from the spec, and looked at that book for entertainment or inspiration.
8:03:10
beach
edgar-rft: Also, have you ever seen a proof by induction that starts with the induction hypothesis and its consequences? Reading code that is structured like that forces the person reading the code to keep in mind stuff that should have been gotten out of the way first.
8:03:54
edgar-rft
I don't consider "Land of Lisp" as a spec replacement but the problem is that it's most often read by *beginners* and then it's important to avoid confusion by all means.
8:07:32
Nilby
I guess that's why SICP is so revered, since I think in manages to be fun and correct and builds the proof from the base.
8:08:21
beach
That sounds right. I certainly don't remember any distractions of this kind from SICP. And that's a good thing.
8:10:32
beach
moon-child: I hope you are not saying that inconsistencies and bad terminology make a book more interesting.
8:12:25
edgar-rft
I'm still thankful to Conrad Barsky for writing a book that doesn't deter beginners with overly technical cruft but as it looks there had been some gaps during the production.
8:12:25
edgar-rft
I also assume that no-starch press is not a super-expensive publisher so we prably have to live with some deficiencies, but maybe there should be a note in the CLiki for example to inform beginners.
8:15:44
Nilby
But I also sometimes think it might be laugh-out-loud funny to see a formal semantics of CL like r5rs.
8:19:18
edgar-rft
engblom: D. Touretzky's "Gentle introduction..." is *very* leightweight, P. Seibel's "Practical Common Lisp" comes next.