Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
34
Task/Ordered-words/Phix/ordered-words.phix
Normal file
34
Task/Ordered-words/Phix/ordered-words.phix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
type ordered(sequence s)
|
||||
for i=1 to length(s)-1 do
|
||||
-- assume all items in the sequence are atoms
|
||||
if s[i]>s[i+1] then
|
||||
return 0
|
||||
end if
|
||||
end for
|
||||
return 1
|
||||
end type
|
||||
|
||||
integer maxlen
|
||||
sequence words
|
||||
object word
|
||||
constant fn = open("demo\\unixdict.txt","r")
|
||||
maxlen = -1
|
||||
|
||||
while 1 do
|
||||
word = gets(fn)
|
||||
if atom(word) then
|
||||
exit
|
||||
end if
|
||||
word = trim(word)
|
||||
if length(word)>=maxlen and ordered(lower(word)) then
|
||||
if length(word)>maxlen then
|
||||
maxlen = length(word)
|
||||
words = {}
|
||||
end if
|
||||
words = append(words,word)
|
||||
end if
|
||||
end while
|
||||
|
||||
close(fn)
|
||||
|
||||
?words
|
||||
Loading…
Add table
Add a link
Reference in a new issue