[NEXT] [PREV]    HANDBOOK / GENTLE PRIMER / Special Patterns and Expressions /

Joker

Gentle
Applications
Concepts
Examples
Handbook
Support
Download

In some cases, one is not interested in all constituents of a term. For example, if we wish to process the head of a list but without consisdering the tail, we may write:


   'rule' ProcessHead(list(Head, Tail)):
      ProcessColor(Head)
In this rule, two variables are defined in a pattern ( Head and Tail), but only one of them is applied in an expression ( Head), In such cases, it is not necessary to invent a name for a variable that is not used (here Tail); instead, we can use a joker, which is written as an underscore (``_'') and matches any value. Hence, the above rule can be rewritten:

   'rule' ProcessHead(list(Head, _)):
      ProcessColor(Head)




[NEXT] [PREV]