small erlang question.

Hal Snyder hal@REDACTED
Fri Jan 16 22:46:42 CET 2004


"R." <meetegriot@REDACTED> writes:

> My question could be stated: is there a way to do a multiple
> condition test with functions in conditions? (I am sure this is, but
> the definition of 'if' and 'case' allows only Patterns (no function)
> and guards (limited set of functions)!). I could use a list of
> conditions and associated Funs, but I would like a more
> straightforward and readable solution (if exists).
>
> Note: the thing that brings me this question is:
> I want to test if a string contains another from a static set of string.
> My first (and incorrect) code would be:
> if (string:str(Text,String)  /= 0) -> ...;
>    (string:str(Text,String2) /= 0) ->...
> end
>
> but string:str is not accepted in a condition. 

Depending on where this is going, consider scanner tools. Not a
general solution for the control flow question asked, but another way
of looking for lots of things inside a string.

Write a leex program?
http://www.erlang.org/examples/examples-2.0.html (parser tutorial)

Write a (f)lex scanner and link it in?
otp_src_R9C-0/lib/megaco/src/flex

(Sorry, still obsessing after previous thread concerning protocol
header parsing.)



More information about the erlang-questions mailing list