http://common-lisp.net/project/quiz/
Quiz #1 has just been posted:
http://common-lisp.net/pipermail/quiz/2006-April/000002.html
enjoy,
--
-Marco
Ring the bells that still can ring.
Forget the perfect offering.
There is a crack in everything.
That's how the light gets in.
-Leonard Cohen
Marco Baringer wrote:
> http://common-lisp.net/project/quiz/
>
> Quiz #1 has just been posted:
>
> http://common-lisp.net/pipermail/quiz/2006-April/000002.html
>
> enjoy,
Nice!
ken
--
Cells: http://common-lisp.net/project/cells/
"Have you ever been in a relationship?"
Attorney for Mary Winkler, confessed killer of her
minister husband, when asked if the couple had
marital problems.
A question in pertinance to the quiz:
How could one write a format directive something to the effect of
;wrong
(format nil "~r ~a~:p" 10 "apricot")
=> "10 apricots"
(format nil "~r ~a~:p" 1 "apricot")
=> "1 apricot"
I would like it to take two arguments, print the first one as a real
then print the second one, a string, with correct pluralization as per
the first argument.
Anyone done this before?
"Tel A." <············@gmail.com> wrote in message ·····························@y43g2000cwc.googlegroups.com...
>A question in pertinance to the quiz:
>
> How could one write a format directive something to the effect of
>
> ;wrong
> (format nil "~r ~a~:p" 10 "apricot")
> => "10 apricots"
>
> (format nil "~r ~a~:p" 1 "apricot")
> => "1 apricot"
>
> I would like it to take two arguments, print the first one as a real
> then print the second one, a string, with correct pluralization as per
> the first argument.
>
> Anyone done this before?
(format nil "~r ~a~:2*~P" 1 "apricot")
---
Geoff
"Geoffrey Summerhayes" <·······@NhOoStPmAaMil.com> writes:
> (format nil "~r ~a~:2*~P" 1 "apricot")
(format nil "~r ~a~2:*~P of beer on the wall" 99 "bottle")
Transpose the 2 and colon. Of course, #'format doesn't seem to be
smart enough to talk about puppies or children. ;)
Ari Johnson <················@gmail.com> writes:
> "Geoffrey Summerhayes" <·······@NhOoStPmAaMil.com> writes:
>
>> (format nil "~r ~a~:2*~P" 1 "apricot")
>
> (format nil "~r ~a~2:*~P of beer on the wall" 99 "bottle")
>
> Transpose the 2 and colon. Of course, #'format doesn't seem to be
> smart enough to talk about puppies or children. ;)
Something can be done:
(dotimes (i 5)
(format t "~D child~:*~[ren~;~:;ren~] & ~:*~D pupp~:*~[ies~;y~:;ies~]~%" i))
0 children & 0 puppies
1 child & 1 puppy
2 children & 2 puppies
3 children & 3 puppies
4 children & 4 puppies
--
__Pascal Bourguignon__ http://www.informatimago.com/
Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we. -- Georges W. Bush
····@mail.ru (Timofei Shatrov) writes:
> On Wed, 03 May 2006 22:35:41 +0200, Pascal Bourguignon
> <···@informatimago.com> tried to confuse everyone with this message:
>
>>Marcin 'Qrczak' Kowalczyk <······@knm.org.pl> writes:
>>> What about Polish? :-)
>>>
>>> 0 szczeniak�w
>>> 1 szczeniak
>>> 2 szczeniaki
>>> 3 szczeniaki
>>> 4 szczeniaki
>>> 5 szczeniak�w
>>> ...
>>> (a form for 1, a form for numbers ending in 2,3,4 except those ending
>>> in 12,13,14, and a form for others)
>>
>
>>0 szceniak�w
>>1 szceniak
>>2 szceniaki
>>3 szceniaki
>>4 szceniak�w
>
> I'm afraid you got it quite wrong :)
Oops, yes, I shifted it down by 1...
> Should be:
>
> (defun polish-number-declination (stream argument colon at &rest
> parameters)
> (declare (ignore colon at parameters))
> (cond
> ((= 1 (mod argument 100)))
> ((and (<= 2 (mod argument 10) 4)
> (not (<= 10 (mod argument 100) 20))
> (princ "i" stream))
> (t (princ "�w" stream))))
>
> I also suspect that different words have different endings depending on
> gender and other stuff.
Yes, that's why I proposed to extend it to convey some meaning to
colon/at or parameters. Unfortunately, my mother never taught me
Polish :-(
--
__Pascal Bourguignon__ http://www.informatimago.com/
PLEASE NOTE: Some quantum physics theories suggest that when the
consumer is not directly observing this product, it may cease to
exist or will exist only in a vague and undetermined state.
····@mail.ru (Timofei Shatrov) writes:
> I also suspect that different words have different endings depending
> on gender and other stuff.
Right, and for this reason the format should list all endings
explicitly.
Here is how GNU gettext does it, and what other languages need:
http://www.gnu.org/software/gettext/manual/html_node/gettext_150.html
--
__("< Marcin Kowalczyk
\__/ ······@knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/
Ari Johnson wrote:
> "Geoffrey Summerhayes" <·······@NhOoStPmAaMil.com> writes:
>
>
>>(format nil "~r ~a~:2*~P" 1 "apricot")
>
>
> (format nil "~r ~a~2:*~P of beer on the wall" 99 "bottle")
>
> Transpose the 2 and colon. Of course, #'format doesn't seem to be
> smart enough to talk about puppies or children. ;)
Well, yes and no:
(format nil "~r ·······@p of beer on the wall" 99 "pupp") =>
"ninety-nine puppies of beer on the wall"
(format nil "~r ·······@p of beer on the wall" 1 "fl") => "one fly of
beer on the wall"
Whatever that means... :)
Aloha,
David Sletten
"Ari Johnson" <················@gmail.com> wrote in message ···················@hermes.theari.com...
> "Geoffrey Summerhayes" <·······@NhOoStPmAaMil.com> writes:
>
>> (format nil "~r ~a~:2*~P" 1 "apricot")
>
> (format nil "~r ~a~2:*~P of beer on the wall" 99 "bottle")
>
<snip>
Bah! Good catch. Serves me right for posting during a
disrupted sleep cycle.
--
Geoff
"Geoffrey Summerhayes" <·······@NhOoStPmAaMil.com> writes:
> "Ari Johnson" <················@gmail.com> wrote...
>> "Geoffrey Summerhayes" <·······@NhOoStPmAaMil.com> writes:
>>
>>> (format nil "~r ~a~:2*~P" 1 "apricot")
>>
>> (format nil "~r ~a~2:*~P of beer on the wall" 99 "bottle")
>>
> <snip>
>
> Bah! Good catch. Serves me right for posting during a
> disrupted sleep cycle.
I confess that it had nothing to do with knowledge and everything to
do with randomly transposing characters until #'format decided to work
for me. :)
Tel A. wrote:
> A question in pertinance to the quiz:
>
> How could one write a format directive something to the effect of
>
> ;wrong
> (format nil "~r ~a~:p" 10 "apricot")
> => "10 apricots"
>
> (format nil "~r ~a~:p" 1 "apricot")
> => "1 apricot"
>
> I would like it to take two arguments, print the first one as a real
> then print the second one, a string, with correct pluralization as per
> the first argument.
>
> Anyone done this before?
>
There's so much magic in FORMAT that it takes a while to get familiar
with it all:
http://www.lispworks.com/documentation/HyperSpec/Body/22_cga.htm
You can use ~n:* to back up n arguments, with 1 the default:
(format nil "~r ~a~:*~:p" 10 "apricot") => "ten apricots"
But based on your description you probably want ~D rather than ~R:
(format nil "~d ~a~:*~:p" 1 "apricot") => "1 apricot"
Unless you actually meant "float" when you wrote "real":
(format nil "~f ~a~:*~:p" 1 "apricot") => "1.0 apricot"
(Remember that you're not really "printing" anything when you use NIL as
the first argument to FORMAT.)
Aloha,
David Sletten