From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: "Peter Stephenson" <pws@ibmth.df.unipi.it>, zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: param stuff and was: PATCH: 3.1.5-pws-12: _brace_parameter
Date: Wed, 17 Mar 1999 15:52:01 +0100 [thread overview]
Message-ID: <9903171452.AA37265@ibmth.df.unipi.it> (raw)
In-Reply-To: ""Andrej Borsenkow""'s message of "Wed, 17 Mar 1999 17:35:30 NFT." <001201be7083$68588150$21c9ca95@mowp.siemens.ru>
"Andrej Borsenkow" wrote:
> >
> > It's actually completely predictable, once you know the rule.
> >
I wrote that rather primly before I discovered the difference between
"${foo[1]}" and "${${(@)foo}[1]}" where foo is an array, which made me
rather less keen on this as a transformational generative grammar :-)
> itsrm2% foo=(axb cxd)
> itsrm2% print -l ${(s/x/)foo}
> a
> b c
> d
>
> itsrm2% foo=("a b" "c d")
> itsrm2% print -l ${=foo}
> a
> b
> c
> d
The rule is that, before splitting, all the words are joined together; by
default this happens with a space. (At least some of this is in the
manual, not necessarily where you want for the present purpose.) So in
both cases the string is first joined with a space (what Chomsky would call
a trace :-) sorry, I'm enjoying myself) and the `deep structure' is
"axb cxd", "a b c d" respectively; in the second it's then split on a
space, too. Compare
% foo=(axb cxd)
% print -l ${(j/x/s/x/)foo
a
b
c
d
where the bit you don't see is now "axbxcxd".
> The second question is, what is applied first - flags or modifications?
> Again, after soms tests :-)
>
> itsrm2% foo=(ax1 bx1)
> itsrm2% print -l ${(s/x/)foo%%1*}
> a
> b
Yes, that's perhaps a bit unexpected and should be documented;
${${(s/x/)foo}%%1*} does what you might have expected.
Now I tried:
% print -l "'"${(j/x/s/x/)^foo%%1*}"'"
'a'
''
'b'
''
where the removal of the 1 seems to happen only after the splitting, so
I'm still a bit confused.
I'll look at the manual when I get a moment, but I'm trying to remember how
to minimize some functions of matrices.
> P.S. Please, don't take me too hard. But just try to pretend itself a ZSH
> newbie for a while ...
This is useful, because people keep complaining that they don't like the
documentation, and then fail to say what's wrong with it. This way we
finally find out.
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
next prev parent reply other threads:[~1999-03-17 15:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-17 9:09 Sven Wischnowsky
1999-03-17 9:59 ` Andrej Borsenkow
1999-03-17 10:08 ` Peter Stephenson
1999-03-17 14:35 ` Andrej Borsenkow
1999-03-17 14:52 ` Peter Stephenson [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-03-17 14:59 Sven Wischnowsky
1999-03-17 10:35 Sven Wischnowsky
1999-03-16 11:50 Sven Wischnowsky
1999-03-15 9:46 Sven Wischnowsky
1999-03-15 13:49 ` Peter Stephenson
1999-03-16 18:07 ` Andrej Borsenkow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9903171452.AA37265@ibmth.df.unipi.it \
--to=pws@ibmth.df.unipi.it \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).