| Bill Allombert on Sun, 25 Feb 2018 11:28:06 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: empty permutation true/false |
On Sun, Feb 25, 2018 at 06:02:44PM +1100, Kevin Ryde wrote:
> I see an empty Vecsmall is true,
>
> if(Vecsmall([]), print("yes"), print("no"));
> => yes
>
> Is that intended, rely on etc? I only wondered since an empty full Vec
> is false, per the user manual (just),
>
> if([], print("yes"), print("no"));
> => no
>
> I have a func where I thought to return a (possibly empty) Vecsmall
> permutation if found, or 0 if not found. That allows if(perm,...) to do
> something when found/not found -- as long as empty permutation is true.
> Or is some other type of "no such permutation" return usual?
You can do
if(perm===0,...)
if you do not want to depend on that.
Cheers,
Bill.