[quiz] [QUIZ 3] reader macro

Larry Clapp larry at theclapp.org
Tue Jul 10 15:03:18 UTC 2007


Okay, here's my 2 cent quiz:

Define a reader macro that reads strings but treats backslashes as
normal characters, except if you escape the string terminator.  This
should work sort of like Perl's single quote string syntax:

Perl:

  $pattern = '\w \s';		# five characters

Lisp:

  (let ((pattern #"\w \s"))	; five characters
    ...)

  as opposed to

  (let ((pattern "\\w \\s"))	; five characters
    ...)

  but this works:

  (let ((pattern #"\w \" \s"))	; seven characters
    ...)

The #" syntax is just to give you an idea of what I want; you can use
whatever macro character(s) you like.

Send answers to the list, preferably with at least one working test
case displayed, e.g. something like

  cl-user> #"\w \" \s"
  "\\w \" \\s"

  cl-user>

-- L


(Yes, this is similar to a previous quiz.  Sue me.)




More information about the Quiz mailing list