Change e letters to i in words: Difference between revisions

Content added Content deleted
(Realize in F#)
(add freebasic)
Line 252: Line 252:
welles -> willis
welles -> willis
</pre>
</pre>

=={{header|FreeBASIC}}==
<lang freebasic>#define NULL 0

type node
word as string*32 'enough space to store any word in the dictionary
nxt as node ptr
end type

function addword( tail as node ptr, word as string ) as node ptr
'allocates memory for a new node, links the previous tail to it,
'and returns the address of the new node
dim as node ptr newnode = allocate(sizeof(node))
tail->nxt = newnode
newnode->nxt = NULL
newnode->word = word
return newnode
end function

function length( word as string ) as uinteger
'necessary replacement for the built-in len function, which in this
'case would always return 32
for i as uinteger = 1 to 32
if asc(mid(word,i,1)) = 0 then return i-1
next i
return 999
end function

dim as string word
dim as node ptr tail = allocate( sizeof(node) )
dim as node ptr head = tail, curr = head, currj
tail->nxt = NULL
tail->word = "XXXXHEADER"

open "unixdict.txt" for input as #1
while true
line input #1, word
if word = "" then exit while
if length(word)>5 then tail = addword( tail, word )
wend
close #1

dim as string tempword
dim as boolean changed

while curr->nxt <> NULL
changed = false
tempword = curr->word
for i as uinteger = 1 to length(tempword)
if mid(tempword,i,1) = "e" then
tempword = left(tempword,i-1) + "i" + mid(tempword, i+1, length(tempword)-i)
changed = true
end if
next i
if changed = true then
currj = head
while currj->nxt <> NULL
if currj->word = tempword then print curr->word, tempword
currj=currj->nxt
wend
end if
curr = curr->nxt
wend</lang>
{{out}}<pre>
analyses analysis
atlantes atlantis
bellow billow
breton briton
clench clinch
convect convict
crises crisis
diagnoses diagnosis
enfant infant
enquiry inquiry
frances francis
galatea galatia
harden hardin
heckman hickman
inequity iniquity
inflect inflict
jacobean jacobian
marten martin
module moduli
pegging pigging
psychoses psychosis
rabbet rabbit
sterling stirling
synopses synopsis
vector victor
welles willis</pre>


=={{header|Go}}==
=={{header|Go}}==