ABC words: Difference between revisions

2,189 bytes added ,  1 month ago
m (→‎{{header|FutureBasic}}: Inserted {{out}} tag)
 
(8 intermediate revisions by 5 users not shown)
Line 1,500:
 
void local fn ABCWords
CFArrayRef list = fn WordList
CFMutableArrayRef words
CFStringRef string
CFArrayRef wordList
CFStringReflong string abc
 
long a, b, c
if ( list ) == NULL then NSLog(@"Unable to load word list") : exit fn
for string in list
wordList = fn WordList
abc = instr( 0, string, @"a")
if ( wordList )
if ( abc == NSNotFound ) then continue
words = fn MutableArrayWithCapacity(0)
abc = instr( abc, string, @"b")
for string in wordList
if ( abc == NSNotFound ) then continue
a = instr(0,string,@"a")
babc = instr(0 abc, string, @"bc")
if ( cabc != instrNSNotFound ) then NSLog(0,string,@"c%@",string)
next
if ( a != NSNotFound and b != NSNotFound and c != NSNotFound and a < b and b < c )
MutableArrayAddObject( words, string )
end if
next
NSLog(@"%@",words)
else
NSLog(@"Unable to load word list")
end if
end fn
 
Line 2,299 ⟶ 2,290:
54 tabernacle
55 tablecloth</pre>
 
=={{header|Pascal}}==
==={{header|Free Pascal}}===
<syntaxhighlight lang="pascal">
Program abcwords;
uses Classes;
 
const
FNAME = 'unixdict.txt';
 
var
list: TStringList;
str : string;
a,b,c : integer;
 
 
begin
list := TStringList.Create;
list.LoadFromFile(FNAME);
for str in list do
begin
a := pos('a',str);
b := pos('b',str);
c := pos('c',str);
if (a>0) and (b>a) and (c > b) then writeln(str);
end;
end.
</syntaxhighlight>
{{out}}
<pre>
aback
abacus
abc
abdicate
abduct
abeyance
abject
abreact
abscess
abscissa
abscissae
absence
abstract
abstracter
abstractor
adiabatic
aerobacter
aerobic
albacore
alberich
albrecht
algebraic
alphabetic
ambiance
ambuscade
aminobenzoic
anaerobic
arabic
athabascan
auerbach
diabetic
diabolic
drawback
fabric
fabricate
flashback
halfback
iambic
lampblack
leatherback
metabolic
nabisco
paperback
parabolic
playback
prefabricate
quarterback
razorback
roadblock
sabbatical
snapback
strabismic
syllabic
tabernacle
tablecloth
</pre>
 
=={{header|Perl}}==
Line 2,649 ⟶ 2,726:
prefabricate quarterback razorback roadblock sabbatical snapback
strabismic syllabic tabernacle tablecloth
</pre>
 
=={{header|R}}==
 
<syntaxhighlight lang="R">
library(stringi)
library(dplyr)
 
check_abc <- function(w) {
char_list <- stri_split_boundaries(w, type='character')[[1]]
fpos <- lapply(c("a","b","c"),\(x) grep(x,char_list)) %>% sapply(\(x) x[1])
if (any(is.na(fpos)==T)) return(F)
ifelse(all(sort(fpos) == fpos),T,F)
}
 
rep <- sapply(readLines("unixdict.txt"), \(x) check_abc(x))
print(names(rep[rep == T]))
</syntaxhighlight>
{{out}}
 
<pre>
[1] "aback" "abacus" "abc" "abdicate" "abduct" "abeyance"
[7] "abject" "abreact" "abscess" "abscissa" "abscissae" "absence"
[13] "abstract" "abstracter" "abstractor" "adiabatic" "aerobacter" "aerobic"
[19] "albacore" "alberich" "albrecht" "algebraic" "alphabetic" "ambiance"
[25] "ambuscade" "aminobenzoic" "anaerobic" "arabic" "athabascan" "auerbach"
[31] "diabetic" "diabolic" "drawback" "fabric" "fabricate" "flashback"
[37] "halfback" "iambic" "lampblack" "leatherback" "metabolic" "nabisco"
[43] "paperback" "parabolic" "playback" "prefabricate" "quarterback" "razorback"
[49] "roadblock" "sabbatical" "snapback" "strabismic" "syllabic" "tabernacle"
[55] "tablecloth"
</pre>
 
Line 3,102 ⟶ 3,210:
</pre>
 
=={{header|V (Vlang)}}==
<syntaxhighlight lang="v (vlang)">
import os
 
Line 3,182 ⟶ 3,290:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "io" for File
import "./fmt" for Fmt
 
var wordList = "unixdict.txt" // local copy
44

edits