rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: rsalz@osf.org
To: rc-owner@hawkwind.utcs.toronto.edu, rc@hawkwind.utcs.toronto.edu
Subject: Re:  list operators
Date: Wed, 15 Sep 1993 15:01:03 -0400	[thread overview]
Message-ID: <9309151901.AA27956@sulphur.osf.org> (raw)

	; * = ( 4 5 6 7 )
	; echo $*
	4 5 6 7
	; shift -3
	; echo $*
	4


# rshift varname count
fn rshift { i=() save=() tmp=() {
	count=`{ expr $#$1 - $2 }
	~ $count -* && { echo cannot rshift >[1=2]; return 1 }
	save=$1
	*=( $$1 )
	for (i) {
	    tmp=( $tmp $i )
	    ~ $#tmp $count && break
	}
	$save=( $tmp )
} }

rn rshift-test {
    foo=(1 2 3 4 5 6)
    echo foo before is $foo
    rshift foo 2
    echo foo after is $foo
    echo

    echo foo before is $foo
    rshift foo 12 || echo rshift failed.
    echo foo after is $foo
}

foo before is 1 2 3 4 5 6
foo after is 1 2 3 4

foo before is 1 2 3 4
cannot rshift
rshift failed.
foo after is 1 2 3 4



             reply	other threads:[~1993-09-15 19:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-09-15 19:01 rsalz [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-09-17 17:32 Stefan Dalibor
1993-09-16 10:11 malte
1993-09-15 21:04 Tom Culliton x2278
1993-09-15 20:47 Brynjulv Hauksson
1993-09-15 19:38 Tom Culliton x2278
1993-09-15 20:08 ` Charles Hannum
1993-09-15 18:29 Byron Rakitzis
1993-09-15 18:28 malte
1993-09-15 18:07 rsalz
1993-09-15 17:55 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=9309151901.AA27956@sulphur.osf.org \
    --to=rsalz@osf.org \
    --cc=rc-owner@hawkwind.utcs.toronto.edu \
    --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).