[erlang-questions] Quickcheck/PropEr: List generator not working as expected
Fri Oct 21 08:08:27 CEST 2011
I see that in your program you have the following:
-define(VOWELS, [$a, $e, $i, $o, $u, $y]).
So far so good. Then you define the following:
-spec consonant() -> proper:test().
?SUCHTHAT(Char, char(), lists:all(fun(C) -> Char /= C end, ?VOWELS)).
Let mention that the above:
1. does not define a proper test; instead, it defines a generator
Good point, need to change the spec 2. seems a complicated (and a bit weird) way of writing a definition
What i need is a char generator that returns all non-vowel chars. What would be a prettier way?
Anyway, the point is that the consonant() generator may look like an
Erlang function, but it's not evaluated to a value once and for all.
Instead, it's evaluated lazily. You should keep this in mind because
it's a subtle point in an otherwise eager language like Erlang.
Thx for the detailed explanation!
Hope this helps,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions