From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from hawkwind.utcs.toronto.edu ([128.100.102.51]) by archone.tamu.edu with SMTP id <18894>; Wed, 11 Sep 1991 17:29:36 -0000 Received: from localhost by hawkwind.utcs.toronto.edu with SMTP id <2708>; Wed, 11 Sep 1991 13:29:25 -0400 To: rc@archone.tamu.edu Subject: Re: a word about shift In-reply-to: malte's message of Wed, 11 Sep 91 13:10:34 -0400. <9109111710.AA06478@dahlie.techfak.uni-bielefeld.de> Date: Wed, 11 Sep 1991 17:29:08 -0000 From: Chris Siebenmann Message-Id: <91Sep11.132925edt.2708@hawkwind.utcs.toronto.edu> 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=$* } }