Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Stupid? format question
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  20 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bob Felts  
View profile  
 More options Jan 23 2009, 10:08 am
Newsgroups: comp.lang.lisp
From: w...@stablecross.com (Bob Felts)
Date: Fri, 23 Jan 2009 10:08:00 -0500
Subject: Stupid? format question
I want to output tabbed data for later input to Excel or FileMaker or...

I can obviously do that with
   (format t "~a---tab goes here---~a~%" field1 field2)

In E-macs I can type C-q Tab to insert a tab.

But I miss the C-style ability to backquote special characters and I
haven't found any equivalent in Lisp.  ~t outputs spaces.  Have I just
overlooked it?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alexander Lehmann  
View profile  
 More options Jan 23 2009, 10:14 am
Newsgroups: comp.lang.lisp
From: Alexander Lehmann <lehma...@in.tum.de>
Date: Fri, 23 Jan 2009 16:14:38 +0100
Local: Fri, Jan 23 2009 10:14 am
Subject: Re: Stupid? format question
Hi Bob,

Bob Felts wrote:
> I want to output tabbed data for later input to Excel or FileMaker or...

does this help?

<http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/f1...>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Antoniotti  
View profile  
 More options Jan 23 2009, 11:00 am
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@gmail.com>
Date: Fri, 23 Jan 2009 08:00:38 -0800 (PST)
Local: Fri, Jan 23 2009 11:00 am
Subject: Re: Stupid? format question
On Jan 23, 4:08 pm, w...@stablecross.com (Bob Felts) wrote:

> I want to output tabbed data for later input to Excel or FileMaker or...

> I can obviously do that with
>    (format t "~a---tab goes here---~a~%" field1 field2)

> In E-macs I can type C-q Tab to insert a tab.

> But I miss the C-style ability to backquote special characters and I
> haven't found any equivalent in Lisp.  ~t outputs spaces.  Have I just
> overlooked it?

    (format t "|~C|~%" #\Tab)

outputs a single tab.  Have also a look at the ~T directive.

Cheers
--
Marco


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Raffael Cavallaro  
View profile  
 More options Jan 23 2009, 11:21 am
Newsgroups: comp.lang.lisp
From: Raffael Cavallaro <raffaelcavall...@pas.espam.s.il.vous.plait.mac.com>
Date: Fri, 23 Jan 2009 11:21:37 -0500
Local: Fri, Jan 23 2009 11:21 am
Subject: Re: Stupid? format question
On 2009-01-23 10:08:00 -0500, w...@stablecross.com (Bob Felts) said:

> But I miss the C-style ability to backquote special characters and I
> haven't found any equivalent in Lisp.  ~t outputs spaces.  Have I just
> overlooked it?

(string #\TAB)   ?
--
Raffael Cavallaro, Ph.D.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alberto Riva  
View profile  
 More options Jan 23 2009, 11:47 am
Newsgroups: comp.lang.lisp
From: Alberto Riva <ar...@nospam.ufl.edu>
Date: Fri, 23 Jan 2009 11:47:34 -0500
Local: Fri, Jan 23 2009 11:47 am
Subject: Re: Stupid? format question
Marco Antoniotti wrote on 01/23/2009 11:00 AM:

> On Jan 23, 4:08 pm, w...@stablecross.com (Bob Felts) wrote:
>> I want to output tabbed data for later input to Excel or FileMaker or...

>> I can obviously do that with
>>    (format t "~a---tab goes here---~a~%" field1 field2)

>> In E-macs I can type C-q Tab to insert a tab.

>> But I miss the C-style ability to backquote special characters and I
>> haven't found any equivalent in Lisp.  ~t outputs spaces.  Have I just
>> overlooked it?

>     (format t "|~C|~%" #\Tab)

> outputs a single tab.  Have also a look at the ~T directive.

And if you have multiple fields you want to print with tabs between them
you can do the following:

   (let ((fmt (format nil "~~{~~a~~^~a~~}" #\tab)))
     (format nil fmt (list field1 field2 field3 ...))

Alberto


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bob Felts  
View profile  
 More options Jan 23 2009, 4:21 pm
Newsgroups: comp.lang.lisp
From: w...@stablecross.com (Bob Felts)
Date: Fri, 23 Jan 2009 16:21:55 -0500
Local: Fri, Jan 23 2009 4:21 pm
Subject: Re: Stupid? format question

Alexander Lehmann <lehma...@in.tum.de> wrote:
> Hi Bob,

> Bob Felts wrote:
> > I want to output tabbed data for later input to Excel or FileMaker or...

> does this help?

> <http://groups.google.com/group/comp.lang.lisp/
>      browse_thread/thread/f104f29d379f3bf8>

Not really, for two reasons.  First, it's CSV and I want tab-delimited
fields.  Second, I've already written the code.  It was easy.

I'm just curious if Lisp has the ability to embed human-readable control
characters in a format string.  I can embed a tab character, but if I
have multiple sequential tabs, I can't tell in Emacs how many I have by
visual inspection.  That is, I have to eyeball a variable number of
spaces and convert them to the equivalent number of tabs, instead of
simply counting \t\t\t.

I can also use ~c along with an argument of #\Tab, but that puts a layer
of indirection between the format string and the output.

Alberto kindly provided this example:

   (let ((fmt (format nil "~~{~~a~~^~a~~}" #\tab)))
     (format nil fmt (list field1 field2 field3 ...))

It's informative and on the one hand I think it's an interesting
technique.  On the other hand, it offends my sense of aesthetics.

Absent something like C's \t (or \n, or \g, or ...), I was hoping that
perhaps there as a reader macro, or something, that could be used inside
of a string to specify a control character.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zach Beane  
View profile  
 More options Jan 23 2009, 4:25 pm
Newsgroups: comp.lang.lisp
From: Zach Beane <x...@xach.com>
Date: Fri, 23 Jan 2009 16:25:47 -0500
Local: Fri, Jan 23 2009 4:25 pm
Subject: Re: Stupid? format question

w...@stablecross.com (Bob Felts) writes:
> Absent something like C's \t (or \n, or \g, or ...), I was hoping that
> perhaps there as a reader macro, or something, that could be used inside
> of a string to specify a control character.

CL-INTERPOL does something like that.

Zach


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
GP lisper  
View profile  
 More options Jan 23 2009, 6:22 pm
Newsgroups: comp.lang.lisp
From: GP lisper <spamb...@CloudDancer.com>
Date: Fri, 23 Jan 2009 15:22:50 -0800
Local: Fri, Jan 23 2009 6:22 pm
Subject: Re: Stupid? format question

On Fri, 23 Jan 2009 16:21:55 -0500, <w...@stablecross.com> wrote:

> I'm just curious if Lisp has the ability to embed human-readable control
> characters in a format string.  I can embed a tab character, but if I
> have multiple sequential tabs, I can't tell in Emacs how many I have by
> visual inspection.

Try hexl-mode

After 22 versions spanning a fair number of years, "can't" rarely
exists in Emacs (and if you give a hacker a hint...).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas A. Russ  
View profile  
 More options Jan 23 2009, 6:18 pm
Newsgroups: comp.lang.lisp
From: t...@sevak.isi.edu (Thomas A. Russ)
Date: 23 Jan 2009 15:18:54 -0800
Local: Fri, Jan 23 2009 6:18 pm
Subject: Re: Stupid? format question

w...@stablecross.com (Bob Felts) writes:
> I want to output tabbed data for later input to Excel or FileMaker or...
...
> In E-macs I can type C-q Tab to insert a tab.

> But I miss the C-style ability to backquote special characters and I
> haven't found any equivalent in Lisp.  ~t outputs spaces.  Have I just
> overlooked it?

Well, the main reason is that lisp strings take their characters
directly and don't really need quoting (except for the string delimiter
" and the escape characer \).  So there isn't any mechanism in Lisp for
quoting characters that don't actually need it.

I suspect that the major difference between lisp and the C-style
languages is that lisp allows you to have line breaks inside your
strings directly.  So for example

 "This is a long string that
 takes up all of three
 separate lines"

is a legal string constant in Lisp, but not in C, C++, Java or most
other languages that I can think of.  So in languages that don't allow
the line breaks into strings, there is a need to quote them.  And if you
are quoting \n and \r, it is only a small leap to add \t, especially for
cases where it might be indistinguishable visually from space.

But since lisp didn't need to have special character quotation in the
first place, it just wasn't added to the language.

(But I do agree that it would sometimes be convenient.)

--
Thomas A. Russ,  USC/Information Sciences Institute


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bob Felts  
View profile  
 More options Jan 23 2009, 8:03 pm
Newsgroups: comp.lang.lisp
From: w...@stablecross.com (Bob Felts)
Date: Fri, 23 Jan 2009 20:03:01 -0500
Local: Fri, Jan 23 2009 8:03 pm
Subject: Re: Stupid? format question

Zach Beane <x...@xach.com> wrote:
> w...@stablecross.com (Bob Felts) writes:

> > Absent something like C's \t (or \n, or \g, or ...), I was hoping that
> > perhaps there as a reader macro, or something, that could be used inside
> > of a string to specify a control character.

> CL-INTERPOL does something like that.

When will I learn to go to Edi's site first?  ;-)
Thanks, Zach.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bob Felts  
View profile  
 More options Jan 23 2009, 8:03 pm
Newsgroups: comp.lang.lisp
From: w...@stablecross.com (Bob Felts)
Date: Fri, 23 Jan 2009 20:03:01 -0500
Local: Fri, Jan 23 2009 8:03 pm
Subject: Re: Stupid? format question

GP lisper <spamb...@CloudDancer.com> wrote:
> On Fri, 23 Jan 2009 16:21:55 -0500, <w...@stablecross.com> wrote:

> > I'm just curious if Lisp has the ability to embed human-readable control
> > characters in a format string.  I can embed a tab character, but if I
> > have multiple sequential tabs, I can't tell in Emacs how many I have by
> > visual inspection.

> Try hexl-mode

> After 22 versions spanning a fair number of years, "can't" rarely
> exists in Emacs (and if you give a hacker a hint...).

Thanks for the pointer.  I'll check it out.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Jan 23 2009, 8:30 pm
Newsgroups: comp.lang.lisp
From: p...@informatimago.com (Pascal J. Bourguignon)
Date: Sat, 24 Jan 2009 02:30:48 +0100
Local: Fri, Jan 23 2009 8:30 pm
Subject: Re: Stupid? format question
t...@sevak.isi.edu (Thomas A. Russ) writes:

And trivial to implement as a reader macro on #\" if you need it.
(Several examples have already been posted in cll).
--
__Pascal Bourguignon__

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William James  
View profile  
 More options Jan 23 2009, 9:23 pm
Newsgroups: comp.lang.lisp
From: "William James" <w_a_x_...@yahoo.com>
Date: 24 Jan 2009 02:23:07 GMT
Local: Fri, Jan 23 2009 9:23 pm
Subject: Re: Stupid? format question

Ruby:

puts ["foo","bar","barely"].join "\t"
foo     bar     barely
    ==>nil


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William James  
View profile  
 More options Jan 23 2009, 9:41 pm
Newsgroups: comp.lang.lisp
From: "William James" <w_a_x_...@yahoo.com>
Date: 24 Jan 2009 02:41:01 GMT
Local: Fri, Jan 23 2009 9:41 pm
Subject: Re: Stupid? format question

It's legal in Ruby and in OCaml, but they allow quoting.
Does this string contain a tab?

"mewler  lisper"

Does this string contain a tab?

"mewler\tlisper"

See the difference?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Jan 23 2009, 9:52 pm
Newsgroups: comp.lang.lisp
From: p...@informatimago.com (Pascal J. Bourguignon)
Date: Sat, 24 Jan 2009 03:52:56 +0100
Local: Fri, Jan 23 2009 9:52 pm
Subject: Re: Stupid? format question

"William James" <w_a_x_...@yahoo.com> writes:
> Does this string contain a tab?

> "mewler  lisper"

> Does this string contain a tab?

> "mewler\tlisper"

> See the difference?

TAB is not a character, it's a control code.  
It has nothing to do in text files or in strings.

You may write:

    (send-string  device "mewler")
    (send-control device 9)
    (send-string  device "lisper")

if you will.

--
__Pascal Bourguignon__


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Antoniotti  
View profile  
 More options Jan 24 2009, 4:05 am
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@gmail.com>
Date: Sat, 24 Jan 2009 01:05:35 -0800 (PST)
Local: Sat, Jan 24 2009 4:05 am
Subject: Re: Stupid? format question
On Jan 24, 3:23 am, "William James" <w_a_x_...@yahoo.com> wrote:

Not the same as Alberto's...  Besides the shortest CL program is

cl-prompt> (tabify '("foo" "bar" "baz"))
foo     bar     baz

Cheers
--
Marco
www.european-lisp-symposium.org


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mirko  
View profile  
 More options Jan 24 2009, 8:06 pm
Newsgroups: comp.lang.lisp
From: Mirko <Mirko.Vuko...@gmail.com>
Date: Sat, 24 Jan 2009 17:06:52 -0800 (PST)
Local: Sat, Jan 24 2009 8:06 pm
Subject: Re: Stupid? format question
On Jan 23, 10:08 am, w...@stablecross.com (Bob Felts) wrote:

> I want to output tabbed data for later input to Excel or FileMaker or...

> I can obviously do that with
>    (format t "~a---tab goes here---~a~%" field1 field2)

> In E-macs I can type C-q Tab to insert a tab.

> But I miss the C-style ability to backquote special characters and I
> haven't found any equivalent in Lisp.  ~t outputs spaces.  Have I just
> overlooked it?

Can I add my own stupid format question?  I will just assume the
answer is yes.  Here it goes:

How can I print "abc" (i.e. the string `abc' enclosed in quotes).
From this discussion I found one way:

(format t "~aabc~a~%" (string #\") (string #\"))

Any way of quoting `"' in the format string itself?

Thank you,

Mirko


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zach Beane  
View profile  
 More options Jan 24 2009, 8:10 pm
Newsgroups: comp.lang.lisp
From: Zach Beane <x...@xach.com>
Date: Sat, 24 Jan 2009 20:10:59 -0500
Local: Sat, Jan 24 2009 8:10 pm
Subject: Re: Stupid? format question

In a string, you can precede " with \ to include " in the string:

  (format t "\"abc\"")

You could also do this:

  (format t "~S" "abc")

That's a little different, though.

Zach


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Jan 24 2009, 8:13 pm
Newsgroups: comp.lang.lisp
From: p...@informatimago.com (Pascal J. Bourguignon)
Date: Sun, 25 Jan 2009 02:13:18 +0100
Local: Sat, Jan 24 2009 8:13 pm
Subject: Re: Stupid? format question

That's a little better I'd say:

C/USER[2]> (progn (format t "\"~A\"~%" "abc\"def")
                  (format t "~S~%" "abc\"def")
                  (values))
"abc"def"
"abc\"def"

C/USER[3]>

--
__Pascal Bourguignon__


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mirko  
View profile  
 More options Jan 24 2009, 8:53 pm
Newsgroups: comp.lang.lisp
From: Mirko <Mirko.Vuko...@gmail.com>
Date: Sat, 24 Jan 2009 17:53:27 -0800 (PST)
Local: Sat, Jan 24 2009 8:53 pm
Subject: Re: Stupid? format question
On Jan 24, 8:13 pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote:

I am sure you two were composing this answer even before I hit the
`send' key.

Thanks :-)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »