~ubuntu-branches/ubuntu/wily/octave-miscellaneous/wily-proposed

« back to all changes in this revision

Viewing changes to inst/grep.m

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Weber
  • Date: 2011-05-12 20:57:43 UTC
  • mto: (1.2.1)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20110512205743-jm1zisr7plt7kvbz
Tags: upstream-1.0.11
ImportĀ upstreamĀ versionĀ 1.0.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
## -*- texinfo -*-
2
 
## @deftypefn{Function File} {@var{[y,f]} = } grep ( x ) 
3
 
## @cindex  
4
 
## This function is just to save typing and improve 
5
 
## readability, as in foo(find(foo(:,p)),p) vs. grep(foo(:,p))
6
 
##
7
 
## You can use grep as follows,
8
 
## @example
9
 
## y = grep(x) = x(find(x))
10
 
## [y,f] = [x(find(x)),find(x)]
11
 
## @end example
12
 
## @seealso{find,strfind}
13
 
## @end deftypefn
14
 
 
15
 
## Author:        Etienne Grossmann <etienne@cs.uky.edu>
16
 
## Last modified: October 2000
17
 
 
18
 
function [y,f] = grep(x)
19
 
y = x(:)(f = find(x));
20
 
## That does not seem to improve anything
21
 
#    if nargout<2,
22
 
#      y = x(find(x));
23
 
#    else
24
 
#      y = x(f = find(x));
25
 
#    end