Remove duplicate elements: Difference between revisions

m
fix markup
m (syntax highlighting fixup automation)
m (fix markup)
Line 993:
The evaluation automatically uses right associativity. So starting with:
 
<syntaxhighlightpre> (1 1 2 1 1)</syntaxhighlightpre>
 
The system places appropriate brackets on the entire expression:
 
<syntaxhighlightpre> (1 ((1 2) (1 1))) </syntaxhighlightpre>
 
Idempotency is applied at rightmost inner brackets:
We get rewrite ''(1 1) -> 1''. The term is now:
<syntaxhighlightpre> (1 ((1 2) 1)) </syntaxhighlightpre>
 
Any further occurrence of 1 will be removed.
Line 1,009:
We get rewrite ''(1 2) -> 2 ''. The term is now:
 
<syntaxhighlightpre>(1 (2 1))</syntaxhighlightpre>
 
By already established idempotency we finally get
 
<syntaxhighlightpre>(2 1)</syntaxhighlightpre>
 
=={{header|Ceylon}}==
10,327

edits