[Grace-core] Short-circuiting elseif

Thomas Kühne Thomas.Kuehne at ecs.vuw.ac.nz
Thu Mar 15 17:29:36 PDT 2012


Michael Homer wrote:
> Alternatively all tests could be in blocks for consistency
> across a call, even though the first one is always guaranteed to
> execute.
>   
One solution is not to support "elseif" but provide a method that takes 
a collection of condition-action associations as the first argument.

|cond [      
  {|sum(data) < 5|}  -> {...}. 
  {|product(data) > 20|}  -> {...}.
] otherwise {...}.|

(Here "[...]" is used to construct a collection and "->" is used to 
construct an association. Grace may have other conventions to accomplish 
this).

Cheers,

    Thomas

-- 
Thomas Kuehne +64 4 463 5443, http://ecs.vuw.ac.nz/~tk
"The difficulty in doing research is to find the right questions so that all the answers come easily" --TK 




More information about the Grace-core mailing list