Re: subset function for string in c++



August Karlstrom wrote
(in article <XSE_e.147284$dP1.504155@xxxxxxxxxxxxxxx>):

> Randy Howard wrote:
>> 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;
>>>
>>>
>>
>>
>> Wow. Ben's version sure seems a lot clearer. :-)
>
> Since the original poster wrote to comp.programming I assumed he/she was
> interested in an algorithm.

I was making a comment on the wordiness of Oberon, not on what
language the solution was in, and it was mostly tongue in cheek.
I would expect a modern language to have a bit more in the way
of standard string support and not have to roll it from scratch,
or is there a more direct way of doing it with Oberon builtins?

> Otherwise comp.lang.c++ is be the appropriate group to consult.

Looked pretty much like conventional C to me. strspn conforms
to ISO C90 according to man pages on this box. :-)

>> I'm having pascal flashbacks, make it stop.
>
> The similarities between Pascal and Oberon is mostly at the syntactic
> level.

Precisely my point. :-)

--
Randy Howard (2reply remove FOOBAR)

.



Relevant Pages

  • Re: subset function for string in c++
    ... >>> Oberon is an efficient minimalist language. ... The inclusion of standard ... > Randy Howard ...
    (comp.programming)
  • Re: Delphi to bytecode compiler
    ... > language, and a cleaner syntax. ... It might be a good idea to use Oberon instead ... > compiler for the existing Delphi syntax is much harder to implement, ...
    (comp.lang.pascal.delphi.misc)
  • Re: [Lit.] Buffer overruns
    ... I will certainly never look at an xor-swap macro the same way ... All of C is pitfall-prone if you don't understand the language. ... I for one like sharp knives, ... Randy Howard ...
    (sci.crypt)
  • Re: Java or C++?
    ... > One approach, taken by Oberon, is to isolate the low level code in ... > "For system-level programming, Oberon offers the pseudo module SYSTEM, ... The C language also has that concept. ... inherently unsafe by their being compiled with the command "cc". ...
    (comp.programming)
  • Re: Which new language to learn?
    ... > Randy Howard wrote: ... views on the C/C++ issue are well documented both in "The design and ... not an outstanding yet incompatible new language. ... other ways of being successful in language design (as well as many ways ...
    (comp.programming)