Re: subset function for string in c++
- From: Duane Bozarth <dpbozarth@xxxxxxxxxxxx>
- Date: Wed, 28 Sep 2005 16:30:50 -0500
August Karlstrom wrote:
>
> puzzlecracker wrote:
> > basically, I need to find out wether charecters in string a are subset
> > of string b..
> >
> >
> > example
> >
> >
> > a: rx b:rwx
> > that shall return true.
> >
>
> As this group is language independent i chose to write an implementation
> in Oberon:
>
> PROCEDURE Subset(a, b: ARRAY OF CHAR): BOOLEAN;
> VAR j, k: LONGINT;
> BEGIN
> j := 0;
> WHILE a[j] # 0X DO
> k := 0;
> WHILE (b[k] # 0X) & (b[k] # a[j]) DO INC(k) END;
> IF b[k] = 0X THEN RETURN FALSE END;
> INC(j)
> END;
> RETURN TRUE
> END Subset;
>
> August
Or,
' Returns true if A is a subset of B, false otherwise.
Function is_subset(a As String, b As String) As Boolean
is_subset = InStr(a, b) > 0
End Function
or, then again,
logical function is_subset(string, substr) result(flg)
character (len=*) :: string, substr
flg = index(string,substr)>0
end function
:)
.
- References:
- Re: subset function for string in c++
- From: August Karlstrom
- Re: subset function for string in c++
- Prev by Date: Re: Am I the only one who has a hard time getting up from the computer?
- Next by Date: Re: Question
- Previous by thread: Re: subset function for string in c++
- Next by thread: Re: subset function for string in c++
- Index(es):
Relevant Pages
|