From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from postman.osf.org ([130.105.1.152]) by hawkwind.utcs.toronto.edu with SMTP id <2776>; Wed, 4 Nov 1992 09:13:06 -0500 Received: from earth.osf.org by postman.osf.org (5.64+/OSF 1.0) id AA29032; Wed, 4 Nov 92 09:12:37 -0500 Received: by earth.osf.org (5.65/4.7) id AA11509; Wed, 4 Nov 92 09:12:36 -0500 Date: Wed, 4 Nov 1992 09:12:36 -0500 From: rsalz@osf.org Message-Id: <9211041412.AA11509@earth.osf.org> To: malte@techfak.uni-bielefeld.de, rc@hawkwind.utcs.toronto.edu Subject: Re: set subtract >A related builtin I always wanted to have: > idx = `{ index list_of_patterns list_to_search_in } >This should return a list of indices of the search patterns in the second list. > ; echo `{ index a ( a b c a ) } > 1 4 Easy; the following just uses built-ins. Note that it implements the example (first arg is a pattern, not a list of patterns); I don't believe the synopsis can be done. fn index { pat=() i=() result=() count=() { pat=$1 shift || { echo 'Usage error' >[1=2] ; return 1 } for (i) { count=(a $count) eval ~ $i $pat && result=($result $#count) } echo $result } }