From: Chris Siebenmann <cks@hawkwind.utcs.toronto.edu>
To: rc@archone.tamu.edu
Subject: Re: a word about shift
Date: Wed, 11 Sep 1991 17:29:08 -0000 [thread overview]
Message-ID: <91Sep11.132925edt.2708@hawkwind.utcs.toronto.edu> (raw)
In-Reply-To: malte's message of Wed, 11 Sep 91 13:10:34 -0400. <9109111710.AA06478@dahlie.techfak.uni-bielefeld.de>
One can write a shift function that shifts an arbitrary list (except '*')
by whatever you want; in fact, I've attached my version at the end of this
message. Given that, I don't think we need to augment shift.
I like shift giving you an error when you try to shift to far; people
who want other behaviors can write wrappers for it. I particularly dislike
options for what shift does; it should do *one* thing, always. See previous
arguments in the mailing list over options.
- cks
# 'supershift' function for rc.
# usage:
# sshift varname
# sshift varname number
# shifts the list varname by number (default 1) positions.
fn sshift { if (~ $#* 1 ) { _sshift $1 1 $$1 } else { _sshift $1 $2 $$1 } }
# this function does most of the work.
# _sshift NAME COUNT LISTELEMS
# shift LISTELEMS COUNT items left, and assign the result to NAME.
fn _sshift { _vn=() { _vn=$1; shift; shift $1; shift; $_vn=$* } }
prev parent reply other threads:[~1991-09-11 17:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1991-09-11 17:10 malte
1991-09-11 17:29 ` Chris Siebenmann [this message]
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=91Sep11.132925edt.2708@hawkwind.utcs.toronto.edu \
--to=cks@hawkwind.utcs.toronto.edu \
--cc=rc@archone.tamu.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).