From: byron@netapp.com (Byron Rakitzis)
To: rc@hawkwind.utcs.toronto.edu
Subject: set subtract
Date: Tue, 3 Nov 1992 18:44:01 -0500 [thread overview]
Message-ID: <9211032344.AA00168@netapp.netapp.com> (raw)
Given two lists a and b, it is possible to do set subtract
in rc with the ~ operator:
for (i in $a)
if (!~ $i $b)
echo $i
So all that you need to do is write a function to build
these two lists based on the
[a] - [b]
syntax suggested. Something like this:
fn set-subtract {
a=()
while () {
switch ($1) {
case ()
echo usage: $0 'foo - bar' >[1=2]
return 1
case -
shift
break
case *
a=($a $1)
shift
}
}
for (i in $a)
if (!~ $i $*)
echo $i
}
(Btw, I would choose a shorter name than set-subtract. Sort of reminds
me of the regexp syntax that Nicklaus Wirth uses in his Oberon system.
I think it's straight BNF. To say .* you have to write it as {~c}. Or
even worse, foo*bar becomes "fo"{"o"}"bar". Does he really use this
tool, or expect anyone else to? But I digress..)
next reply other threads:[~1992-11-04 0:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1992-11-03 23:44 Byron Rakitzis [this message]
1992-11-04 0:42 ` Chris Siebenmann
[not found] <cks@hawkwind.utcs.toronto.edu>
1992-11-04 12:45 ` malte
1992-11-04 14:12 rsalz
1992-11-04 14:25 malte
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=9211032344.AA00168@netapp.netapp.com \
--to=byron@netapp.com \
--cc=rc@hawkwind.utcs.toronto.edu \
/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.
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).