[erlang-questions] Quickcheck/PropEr: List generator not working as expected

Ward Bekker ward@REDACTED
Fri Oct 21 08:08:27 CEST 2011


Hi Kostis,
  _____  

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().
  consonant() ->
       ?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 
  for consonants...
 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,
  Kostis
    
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111021/e85ebee3/attachment.htm>


More information about the erlang-questions mailing list