I before E except after C: Difference between revisions

m
imported>Thebeez
m (→‎{{header|Wren}}: Minor tidy)
(2 intermediate revisions by 2 users not shown)
Line 1,001:
print "plausible."
end</syntaxhighlight>
 
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<syntaxhighlight lang="bbcbasic"> F%=OPENIN"unixdict.txt"
IF F% == 0 ERROR 100, "unixdict not found!"
 
CI=0 : XI=0 : CE=0 : XE=0
WHILE NOT EOF#F%
Line$=GET$#F%
P%=INSTR(Line$, "ie")
WHILE P%
IF MID$(Line$, P% - 1, 1) == "c" CI+=1 ELSE XI+=1
P%=INSTR(Line$, "ie", P% + 1)
ENDWHILE
P%=INSTR(Line$, "ei")
WHILE P%
IF MID$(Line$, P% - 1, 1) == "c" CE+=1 ELSE XE+=1
P%=INSTR(Line$, "ei", P% + 1)
ENDWHILE
ENDWHILE
CLOSE#F%
 
PRINT "Instances of 'ie', proceeded by a 'c' = ";CI
PRINT "Instances of 'ie', NOT proceeded by a 'c' = ";XI
P1%=XI * 2 > CI
PRINT "Therefore 'I before E when not preceded by C' is" FNTest(P1%)
PRINT
 
PRINT "Instances of 'ei', proceeded by a 'c' = ";CE
PRINT "Instances of 'ei', NOT proceeded by a 'c' = ";XE
P2%=CE * 2 > XE
PRINT "Therefore 'E before I when preceded by C' is" FNTest(P2%)
PRINT
 
IF P1% AND P2% PRINT "B"; ELSE PRINT "Not b";
PRINT "oth sub-phrases are plausible, therefore the phrase " +\
\ "'I before E, except after C' can be said to be" FNTest(P1% AND P2%) "!"
END
 
DEF FNTest(plausible%)=MID$(" not plausible", 1 - 4 * plausible%)</syntaxhighlight>
{{out}}
<pre>Instances of 'ie', proceeded by a 'c' = 24
Instances of 'ie', NOT proceeded by a 'c' = 466
Therefore 'I before E when not preceded by C' is plausible
 
Instances of 'ei', proceeded by a 'c' = 13
Instances of 'ei', NOT proceeded by a 'c' = 217
Therefore 'E before I when preceded by C' is not plausible
 
Not both sub-phrases are plausible, therefore the phrase 'I before E, except after C' can be said to be not plausible!</pre>
 
=={{header|BCPL}}==
Line 4,383 ⟶ 4,435:
(To be plausible, one word count must exceed another by 2 times)
</pre>
 
=={{header|SETL}}==
<syntaxhighlight lang="setl">program i_before_e_except_after_c;
init cie := 0, xie := 0, cei := 0, xei := 0;
 
dict := open("unixdict.txt", "r");
loop doing word := getline(dict); while word /= om do
classify(word);
end loop;
close(dict);
 
p :=
plausible("I before E when not preceded by C", xie, cie) and
plausible("E before I when preceded by C", cei, xei);
print;
print("I before E, except after C:" + (if p then "" else " not" end)
+ " plausible.");
 
proc classify(word);
if "ie" in word then
if "cie" in word then cie +:= 1;
else xie +:= 1;
end if;
elseif "ei" in word then
if "cei" in word then cei +:= 1;
else xei +:= 1;
end if;
end if;
end proc;
 
proc plausible(clause, feature, opposite);
p := 2 * feature > opposite;
print(clause + ":" + (if p then "" else " not" end) + " plausible.");
return p;
end proc;
end program;</syntaxhighlight>
{{out}}
<pre>I before E when not preceded by C: plausible.
E before I when preceded by C: not plausible.
 
I before E, except after C: not plausible.</pre>
 
=={{header|Swift}}==
Line 4,446 ⟶ 4,539:
E before I when preceded by C is not plausable
I before E except after C is not plausible</pre>
 
 
=={{header|True BASIC}}==
Line 4,988 ⟶ 5,080:
 
Also there are seven words which fall into two categories and which have therefore been double-counted.
<syntaxhighlight lang="ecmascriptwren">import "io" for File
import "./pattern" for Pattern
import "./fmt" for Fmt
 
var yesNo = Fn.new { |b| (b) ? "yes" : "no" }
Line 5,070 ⟶ 5,162:
And the code and results for the 'stretch goal' which has just the one double-counted word:
 
<syntaxhighlight lang="ecmascriptwren">import "io" for File
import "./pattern" for Pattern
import "./fmt" for Fmt
 
var yesNo = Fn.new { |b| (b) ? "yes" : "no" }
Line 5,149 ⟶ 5,241:
Plausible overall: no
</pre>
 
 
=={{header|Yabasic}}==
9,482

edits