Re: subset function for string in c++



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 .



Relevant Pages

  • Re: subset function for string in c++
    ... Randy Howard wrote: ... of string b.. ... VAR j, k: LONGINT; ...
    (comp.programming)
  • Re: Help Setting HTML Color?
    ... function Sto_ColorToHtml: String; ... iHtml: Longint; ... // converts an html color string to a color, ...
    (borland.public.delphi.language.objectpascal)
  • Re: subset function for string in c++
    ... puzzlecracker wrote: ... of string b.. ... VAR j, k: LONGINT; ...
    (comp.programming)
  • A general solution
    ... Split on an array of delimiters; parse a file in one call. ... Hi Gerry,If the string is using comma to separate name and using quotation ... var element; ... Gerry Hickman wrote: ...
    (microsoft.public.scripting.jscript)
  • Re: Calculate the string statement
    ... verkn:(vkn:char; ... funkt:(fkt:string; ... var fkt,dfkt: p; ... var fehler: boolean; ...
    (comp.lang.pascal.borland)