Веб Зображення Новини Групи Блоги Перекладач Gmail Ще »
Групи, які ви переглядали нещодавно | Довідка | Увійти
Головна сторінка Груп Google
tagbody vs. defun
Занадто багато тем, що мають бути показані першими. Для того, щоб показати тему першою, зніміть цю опцію з іншої теми.
Під час обробки вашого запиту сталася помилка. Будь ласка, повторіть вашу спробу пізніше.
флаг
  Повідомлення 26 - 36 із 36 - Згорнути всі  -  Перекласти все вказаною мовою: Перекладено (переглянути всі оригінали) < Старіші 
Група, до якої ви додаєте допис, - група Usenet. Відтак, будь-хто в Інтернеті бачитиме вашу електронну адресу.
Вашу відповідь не було надіслано.
Ваш допис надіслано
 
Від:
Кому:
Копія:
Продолжить:
Додати копію: | Додати продовження: | Редагувати тему
Тема:
Підтвердження:
З метою підтвердження введіть символи, наведені на зображенні нижче, або числа, які чуєте, натиснувши значок доступу. Прослухайте і введіть цифри, що чуєте
 

* (Rob Warnock) <JNCdna0dGt6oP3bXnZ2dnUVZ_uOdn...@speakeasy.net> :
Wrote on Fri, 30 Oct 2009 21:34:29 -0500:

| Thomas A. Russ <t...@sevak.isi.edu> wrote:
| +---------------

| | x...@unnamed.xach.com writes:

| | > When possible, I prefer obfuscation through FORMAT.
| |
| | You mean like
| |  (format t "one ~a~%~:*two ~a~%~:*three ~a~%" x)
| +---------------
|
| *ROTFLMAO!!* I immediately thought of Lily Tomlin's character Ernestine:
|
|     (let* ((x (format nil "r~a-~:*d~a..." "ingy")))
|       (format t "one ~a~%~:*two ~a~%~:*three ~a~%" x))
|

I missed the cultural reference, so I do not understand what you are
trying to demonstrate here, but _whatever_ it is, it can be done way
more elegantly Using Recursion; and by Adding a Level of Indirection
(which also has advantage of avoiding a style warning for LET*!)

(let* ((y (format nil "r~a-~:*d~a..." "ingy"))
       (x (format nil
      "~~#[three ~a~%~:*~~;two ~a~%~:*~~@?~~;one ~a~%~~@?~~:;~~@?~~]" y)))
  (format nil x x x))

--
Madhu


Ви мусите увійти перед публікацією повідомлень.
Аби надіслати допис, будь ласка, спочатку приєднайтеся до цієї групи.
Будь ласка, поновіть своє прізвисько на сторінці налаштування передплати перед тим, як надіслати свій допис.
У вас немає права надсилання дописів до цієї групи.
Madhu <enom...@meer.net> wrote:

+---------------
| * Rob Warnock wrote:
| | Thomas A. Russ <t...@sevak.isi.edu> wrote:
| | +---------------
| | | You mean like
| | |  (format t "one ~a~%~:*two ~a~%~:*three ~a~%" x)
| | +---------------
| |
| | *ROTFLMAO!!* I immediately thought of Lily Tomlin's character Ernestine:
| |
| |     (let* ((x (format nil "r~a-~:*d~a..." "ingy")))
| |       (format t "one ~a~%~:*two ~a~%~:*three ~a~%" x))
|
| I missed the cultural reference, so I do not understand what you are
| trying to demonstrate here...
+---------------

See:

    http://en.wikipedia.org/wiki/Lily_Tomlin
    ...
    Career
    In 1969, Tomlin joined the sketch comedy show Laugh-In. Some
    characters from the show have been associated with her throughout
    her career, including the wisecracking, snorting telephone
    operator, Ernestine; ...

Ernestine was known for placing telephone calls to victims\\\\\ customers
and, while waiting for the call to be answeredr, saying the output from
the above FORMAT out loud, to wit:

    one ringy-dingy...
    two ringy-dingy...
    three ringy-dingy...

+---------------
| (which also has advantage of avoiding a style warning for LET*!)
+---------------

Sorry 'bout that. An earlier version looked like this:

    (let* ((s "ingy")
           (x (format nil "r~a-d~a..." s s)))
      (format t "one ~a~%~:*two ~a~%~:*three ~a~%" x))

but I realized I could use the backup trick to avoid duplicating
the string arg and so got rid of the temporary variable S, but then
didn't change the LET* to a LET. Happens a lot in exploratory code.

[Note that none of CMUCL, CLISP, nor SBCL (at least, not the versions to
which I have access) give the annoying, overprotective "style warning" for
a LET* with only one binding that your implementation apparently does.]

-Rob

-----
Rob Warnock                     <r...@rpw3.org>
627 26th Avenue                 <URL:http://rpw3.org/>
San Mateo, CA 94403             (650)572-2607


Ви мусите увійти перед публікацією повідомлень.
Аби надіслати допис, будь ласка, спочатку приєднайтеся до цієї групи.
Будь ласка, поновіть своє прізвисько на сторінці налаштування передплати перед тим, як надіслати свій допис.
У вас немає права надсилання дописів до цієї групи.
* (Rob Warnock) <e6WdnbQQ5sPutXHXnZ2dnUVZ_qKdn...@speakeasy.net> :
Wrote on Sat, 31 Oct 2009 07:07:15 -0500:

| [Note that none of CMUCL, CLISP, nor SBCL (at least, not the versions to
| which I have access) give the annoying, overprotective "style warning" for
| a LET* with only one binding that your implementation apparently does.]

No I don't think I've used an implementation that spat this warning
either, but I'd bet SBCL did it at some point.

[Note I _had_ to avoid a smiley at all costs.  I was afraid this
 sentence might have given it away.]

--
Madhu


Ви мусите увійти перед публікацією повідомлень.
Аби надіслати допис, будь ласка, спочатку приєднайтеся до цієї групи.
Будь ласка, поновіть своє прізвисько на сторінці налаштування передплати перед тим, як надіслати свій допис.
У вас немає права надсилання дописів до цієї групи.

On Fri, 30 Oct 2009 21:34:29 -0500, r...@rpw3.org (Rob Warnock) said:

> Thomas A. Russ <t...@sevak.isi.edu> wrote:
> +---------------
> | x...@unnamed.xach.com writes:
> | > When possible, I prefer obfuscation through FORMAT.
> |
> | You mean like
> |  (format t "one ~a~%~:*two ~a~%~:*three ~a~%" x)
> +---------------
> *ROTFLMAO!!* I immediately thought of Lily Tomlin's character Ernestine:
>     (let* ((x (format nil "r~a-~:*d~a..." "ingy")))
>       (format t "one ~a~%~:*two ~a~%~:*three ~a~%" x))

  To paraphrase a friend of mine, if we shall obfuscate, then let us
  obfuscate:

    * (format t "~3@{~'R/++/ ~@?~%~@*~}" '#:ernestine "r~A-~:*d~A..." "ingy")
    one ringy-dingy...
    two ringy-dingy...
    three ringy-dingy...
    NIL

  where

    (shadow '++)
    (let ((counters (make-hash-table)))
    (defun reset-counter (counter &optional (value 0))
      (setf (gethash counter counters) value))
    (defun ++ (stream counter colonp atsignp &rest parameters)
      (destructuring-bind (&optional number-format) parameters
        (let ((format-string (format nil "~~~A~A~A"
                                     (if colonp ":" "")
                                     (if atsignp "@" "")
                                     (or number-format #\D))))
          (format stream format-string (incf (gethash counter counters 0))))))
    (values 'reset-counter '++))

  (and I don't claim to have exhausted all possibilities).

  ---Vassil.

--
"Even when the muse is posting on Usenet, Alexander Sergeevich?"


Ви мусите увійти перед публікацією повідомлень.
Аби надіслати допис, будь ласка, спочатку приєднайтеся до цієї групи.
Будь ласка, поновіть своє прізвисько на сторінці налаштування передплати перед тим, як надіслати свій допис.
У вас немає права надсилання дописів до цієї групи.

Oh, and another way to obfuscate ^W do the ringy-dingy count is:

  (let ((counter 0))
    (format t "~3@{~'R/$/ r~A-~:*d~A...~%~@*~}" (by-name (incf counter)) "ingy"))

or, if you are that way inclined,

  (let ((n 0))
    (symbol-macrolet ((counter #'(lambda () (incf n))))
      (format t "~3@{~'R/$/ r~A-~:*d~A...~%~@*~}" counter "ingy")))

where

  (defun $ (stream argument colonp atsignp &rest parameters)
    ;; do we want to signal an error if we are supplied too many parameters?
    (destructuring-bind (&optional directive) parameters
      (let ((format-string (format nil "~~~A~A~A"
                                   (if colonp ":" "")
                                   (if atsignp "@" "")
                                   (or directive #\S))))
        (format stream format-string (funcall argument)))))

  (defmacro by-name (form) `#'(lambda () ,form))

---Vassil.

--
"Even when the muse is posting on Usenet, Alexander Sergeevich?"


Ви мусите увійти перед публікацією повідомлень.
Аби надіслати допис, будь ласка, спочатку приєднайтеся до цієї групи.
Будь ласка, поновіть своє прізвисько на сторінці налаштування передплати перед тим, як надіслати свій допис.
У вас немає права надсилання дописів до цієї групи.
Tamas K Papp <tkp...@gmail.com> writes:

> I am still not sure that the OP is a troll.  He could be coming from
> another language, and be under the impression that people start
> learning CL from the Hyperspec.

That was a _huge_ stumbiling block back in 2000 or 2001 when I first
gave Lisp a try.  Back then there were basically no free tutorials and
the HyperSpec was about all that was available.

I think I got to reading about PROGN, PROGV and friends before running
away screaming.

Then Practical Common Lisp came out and life was good.  Thanks Peter!

--
That's what I say when people ask me 'aren't you scared of the traffic?'
'Why?  The cars are all stopped.'  And they look sheepish and agree that
 commuting on a bicycle in peak hour isn't that much of a problem.
                                                --Zebee Johnstone


Ви мусите увійти перед публікацією повідомлень.
Аби надіслати допис, будь ласка, спочатку приєднайтеся до цієї групи.
Будь ласка, поновіть своє прізвисько на сторінці налаштування передплати перед тим, як надіслати свій допис.
У вас немає права надсилання дописів до цієї групи.
Vassil Nikolov skreiv:

> Oh, and another way to obfuscate ^W do the ringy-dingy count is:

>   (let ((counter 0))
>     (format t "~3@{~'R/$/ r~A-~:*d~A...~%~@*~}" (by-name (incf counter)) "ingy"))

Format is a nice tool, it can even do the counting for us:

(format
  t "~1{~#@{~:[~#*~:*~;~:*~#/cl:format/ ~:*~0:/cl:format/...~%~2:*~]~}~}"
  `(nil ,@(loop repeat 3 collect "~:[~1*~R~;~2@{~:[r~;d~]ingy~^-~}~]")))

If you want more or less ringy-dingies just change the number 3 between
  repeat and collect.

Note that this code does not use format to build the format string. This
way subtle bugs are avoided and the code becomes simple and easy to
understand.


Ви мусите увійти перед публікацією повідомлень.
Аби надіслати допис, будь ласка, спочатку приєднайтеся до цієї групи.
Будь ласка, поновіть своє прізвисько на сторінці налаштування передплати перед тим, як надіслати свій допис.
У вас немає права надсилання дописів до цієї групи.

On Thu, 05 Nov 2009 00:50:26 +0100, Thomas Bakketun <tho...@bakketun.net> said:

> ...
> Format is a nice tool, it can even do the counting for us:
> (format
>  t "~1{~#@{~:[~#*~:*~;~:*~#/cl:format/ ~:*~0:/cl:format/...~%~2:*~]~}~}"
>  `(nil ,@(loop repeat 3 collect "~:[~1*~R~;~2@{~:[r~;d~]ingy~^-~}~]")))

  That's the spirit!

> ...
> Note that this code does not use format to build the format
> string. This way subtle bugs are avoided and the code becomes simple
> and easy to understand.

  :- )

  ---Vassil.

--
"Even when the muse is posting on Usenet, Alexander Sergeevich?"


Ви мусите увійти перед публікацією повідомлень.
Аби надіслати допис, будь ласка, спочатку приєднайтеся до цієї групи.
Будь ласка, поновіть своє прізвисько на сторінці налаштування передплати перед тим, як надіслати свій допис.
У вас немає права надсилання дописів до цієї групи.
Den Thu, 05 Nov 2009 00:50:26 +0100, skrev Thomas Bakketun:

I'd like to give a example from another language that if famous for it's
clarity of exposition.

Here is the winner of "The Perl Journal's Obfuscated Perl Contest in
2000":

#:: ::-| ::-| .-. :||-:: 0-| .-| ::||-| .:|-. :||
open(Q,$0);while(<Q>){if(/^#(.*)$/){for(split('-',$1)){$q=0;for(split){s\|
/:.:/xg;s/:/../g;$Q=$_?length:$_;$q+=$q?$Q:$Q*20;}print chr($q);print"\n";
#.: ::||-| .||-| :|||-| ::||-| ||-:: :|||-| .:|

prints "The Perl Journal"

http://mysite.verizon.net/les.peters/id2.html


Ви мусите увійти перед публікацією повідомлень.
Аби надіслати допис, будь ласка, спочатку приєднайтеся до цієї групи.
Будь ласка, поновіть своє прізвисько на сторінці налаштування передплати перед тим, як надіслати свій допис.
У вас немає права надсилання дописів до цієї групи.
* Thomas Bakketun <7leia3F3di31...@mid.individual.net> :
Wrote on Thu, 05 Nov 2009 00:50:26 +0100:

| Format is a nice tool, it can even do the counting for us:

Excellent!  

I'm not sure about one construct being portable CL though:

| (format
|  t "~1{~#@{~:[~#*~:*~;~:*~#/cl:format/ ~:*~0:/cl:format/...~%~2:*~]~}~}"
------------------------------------------------------------^^^^^^
|  `(nil ,@(loop repeat 3 collect "~:[~1*~R~;~2@{~:[r~;d~]ingy~^-~}~]")))
|

The problem is with the `~2:*' in the main format string.  22.3.7.1 says
``When within a ~{ construct (see below), the ignoring (in either
direction) is relative to the list of arguments being processed by the
iteration.''

When the ~2:* is encountered, we are processing a list in the inner
iteration and are at the second element of _this_ list being processed.
An implementation is free to throw an error since it cannot skip more
than 2 elements backwards in a list of length 1.

I think LW's implementation follows this interpretation of the spec.

--
Madhu


Ви мусите увійти перед публікацією повідомлень.
Аби надіслати допис, будь ласка, спочатку приєднайтеся до цієї групи.
Будь ласка, поновіть своє прізвисько на сторінці налаштування передплати перед тим, як надіслати свій допис.
У вас немає права надсилання дописів до цієї групи.
* Thomas Bakketun <7leia3F3di31...@mid.individual.net> :
Wrote on Thu, 05 Nov 2009 00:50:26 +0100:

| Format is a nice tool, it can even do the counting for us:

Excellent!  

I'm not sure about one construct being portable CL though:

| (format
|  t "~1{~#@{~:[~#*~:*~;~:*~#/cl:format/ ~:*~0:/cl:format/...~%~2:*~]~}~}"
------------------------------------------------------------^^^^^^
|  `(nil ,@(loop repeat 3 collect "~:[~1*~R~;~2@{~:[r~;d~]ingy~^-~}~]")))
|

The problem is with the `~2:*' in the main format string.  22.3.7.1 says
``When within a ~{ construct (see below), the ignoring (in either
direction) is relative to the list of arguments being processed by the
iteration.''

When the ~2:* is encountered, we are processing a list in the inner
iteration and are at the second element of _this_ list being processed.
An implementation is free to throw an error since it cannot skip more
than 2 elements backwards in a list at position 1.

I think LW's implementation follows this interpretation of the spec.

--
Madhu


Ви мусите увійти перед публікацією повідомлень.
Аби надіслати допис, будь ласка, спочатку приєднайтеся до цієї групи.
Будь ласка, поновіть своє прізвисько на сторінці налаштування передплати перед тим, як надіслати свій допис.
У вас немає права надсилання дописів до цієї групи.
Кінець повідомлень < Старіші 
« Повернутися до обговорень « Новіша тема     Старіша тема »

Створити групу - Групи Google - Домашня сторінка Google - Правила користування послугою - Заява про конфіденційність і нерозголошення інформації
©2009 Google