Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: deleting 0s from an array
Date: Fri, 17 Aug 2007 09:43:57 -0400
Organization: The MathWorks, Inc.
Lines: 38
Message-ID: <fa48mt$8lv$1@fred.mathworks.com>
References: <fa07po$f1c$1@fred.mathworks.com> <fa08s1$r4b$1@fred.mathworks.com> <1187326130.279914.104760@g12g2000prg.googlegroups.com> <fa3kot$4mp$1@fred.mathworks.com> <fa3n8c$1an$1@canopus.cc.umanitoba.ca>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1187358237 8895 144.212.105.187 (17 Aug 2007 13:43:57 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 17 Aug 2007 13:43:57 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
Xref: news.mathworks.com comp.soft-sys.matlab:424300



"Walter Roberson" <roberson@ibd.nrc-cnrc.gc.ca> wrote in message 
news:fa3n8c$1an$1@canopus.cc.umanitoba.ca...
> In article <fa3kot$4mp$1@fred.mathworks.com>, us  <us@neurol.unizh.ch> 
> wrote:
>>Richard Brown:
>><SNIP pseudo-golf...
>
>>> > d(~d)=[]    %provided d does not contain a nan
>
>>> I can tie:
>>> d=d(~~d)
>
>>again, and as <walter roberson> pointed out: as long as <d>
>>is finite... now, to test this would (probably) cost you an
>>extra few chars...


Add one more character and you get a version that works for inf, -inf, NaN, 
and finite numbers.

> d(~d)=[] and d=d(~~d) work for inf and -inf but neither works for NaN.
>
> -- 
>   Okay, buzzwords only. Two syllables, tops.  -- Laurie Anderson

% This line doesn't count in the score; it generates sample data to test the 
solution
d = [0 1 2 -5 0 324.65 Inf 0 -Inf NaN 0];

% Hole in 9
d=d(d~=0)

-- 
Steve Lord
slord@mathworks.com