I before E except after C: Difference between revisions

Content added Content deleted
(Add Go example.)
m (Correct Go example.)
Line 271: Line 271:


check(ie, cie, "I before E when not preceded by C")
check(ie, cie, "I before E when not preceded by C")
check(cei, ei, "I before E when not preceded by C")
check(cei, ei, "E before I when preceded by C")
}
}


Line 278: Line 278:
func check(a, b int, s string) {
func check(a, b int, s string) {
if a > b*2 {
if a > b*2 {
fmt.Printf("%q is plausible.\n", s)
fmt.Printf("%q is plausible (%d vs %d).\n", s, a, b)
} else {
} else {
fmt.Printf("%q is implausible.\n", s)
fmt.Printf("%q is implausible (%d vs %d).\n", s, b, a)
}
}
}
}
</lang>
</lang>

Output:
<pre>
"I before E when not preceded by C" is plausible (465 vs 24).
"E before I when preceded by C" is implausible (213 vs 13).
</pre>


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==