Ordered words: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
No edit summary
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 239:
glossy
knotty</pre>
 
=={{header|APL}}==
Works in NARS2000 APL; ("Objects" menu -> New, paste this in, save. Then run in the main session manager).
Line 267 ⟶ 268:
abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty
</pre>
 
=={{header|AutoHotkey}}==
This script uses the ASCII value of each letter to determine its place in the alphabet. Given a dictionary not all in the same case,
Line 792 ⟶ 794:
return 0;
}</lang>
 
=={{header|C sharp|C#}}==
<lang csharp>using System;
using System.Linq;
using System.Net;
 
static class Program
{
static void Main(string[] args)
{
WebClient client = new WebClient();
string text = client.DownloadString("http://www.puzzlers.org/pub/wordlists/unixdict.txt");
string[] words = text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
 
var query = from w in words
where IsOrderedWord(w)
group w by w.Length into ows
orderby ows.Key descending
select ows;
 
Console.WriteLine(string.Join(", ", query.First().ToArray()));
}
 
private static bool IsOrderedWord(string w)
{
for (int i = 1; i < w.Length; i++)
if (w[i] < w[i - 1])
return false;
 
return true;
}
}</lang>
 
Output:
<pre>abbott, accent, accept, access, accost, almost, bellow, billow, biopsy, chilly, choosy, choppy, effort, floppy, glossy, knotty</pre>
 
=={{header|C++}}==
Line 852 ⟶ 889:
knotty
</pre>
 
=={{header|C sharp|C#}}==
<lang csharp>using System;
using System.Linq;
using System.Net;
 
static class Program
{
static void Main(string[] args)
{
WebClient client = new WebClient();
string text = client.DownloadString("http://www.puzzlers.org/pub/wordlists/unixdict.txt");
string[] words = text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
 
var query = from w in words
where IsOrderedWord(w)
group w by w.Length into ows
orderby ows.Key descending
select ows;
 
Console.WriteLine(string.Join(", ", query.First().ToArray()));
}
 
private static bool IsOrderedWord(string w)
{
for (int i = 1; i < w.Length; i++)
if (w[i] < w[i - 1])
return false;
 
return true;
}
}</lang>
 
Output:
<pre>abbott, accent, accept, access, accost, almost, bellow, billow, biopsy, chilly, choosy, choppy, effort, floppy, glossy, knotty</pre>
 
 
=={{header|Clojure}}==
Line 1,223 ⟶ 1,224:
→ (Adelops alloquy beefily begorry billowy egilops)
</lang>
 
 
=={{header|Elixir}}==
Line 1,457:
<pre>abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty
</pre>
 
=={{header|FBSL}}==
Downloads the list from puzzlers.org.
Line 1,914 ⟶ 1,915:
glossy
knotty</pre>
 
=={{header|Haskell}}==
<lang haskell>
Line 2,178 ⟶ 2,180:
});
});</lang>
 
=={{header|jq}}==
{{works with|jq|1.4}}
Line 2,310 ⟶ 2,313:
{{out}}
<pre>[ abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty ]</pre>
 
 
=={{header|Lasso}}==
Line 2,506 ⟶ 2,508:
"glossy"
"knotty"</pre>
 
 
=={{header|Mathematica}}==
Line 2,802 ⟶ 2,803:
s: Return left('s',arg(1)>1)</lang>
{{out}}
Same as REXX'
 
=={{header|PARI/GP}}==
Line 2,829 ⟶ 2,830:
<pre>
abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty
</pre>
 
=={{header|Perl 6}}==
 
Here we assume the dictionary is provided on standard input.
 
{{works with|Rakudo|2016.07}}
<lang perl6>say lines.grep({ [le] .comb }).classify(*.chars).max(*.key).value</lang>
 
{{out}}
<pre>
[abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty]
</pre>
 
Line 3,279 ⟶ 3,268:
knotty
</pre>
 
=={{header|Raku}}==
(formerly Perl 6)
 
Here we assume the dictionary is provided on standard input.
 
{{works with|Rakudo|2016.07}}
<lang perl6>say lines.grep({ [le] .comb }).classify(*.chars).max(*.key).value</lang>
 
{{out}}
<pre>
[abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty]
</pre>
 
=={{header|Red}}==
<lang Red>Red []
Line 3,298 ⟶ 3,301:
<pre>["abbott" "accent" "accept" "access" "accost" "almost" "bellow" "billow" "biopsy" "chilly" "choosy" "choppy" "effort" "floppy" "glossy" "knotty"]
</pre>
 
=={{header|REXX}}==
This problem assumes (or implies) an order of letter case, but fortunately, there're no uppercase letters
Line 3,569 ⟶ 3,573:
knotty
</pre>
 
=={{header|Scheme}}==
The following implementation uses a <tt>char>=?</tt> procedure that accepts an arbitrary number of arguments. This is allowed, but not required, by R5RS, and is provided by many Scheme implementations. It has been tested under GNU Guile 1.8.8.
Line 3,702 ⟶ 3,707:
{{out}}
<pre>abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty</pre>
 
=={{header|Simula}}==
<lang simula>BEGIN
Line 4,126 ⟶ 4,132:
knotty
</pre>
 
=={{header|Vedit macro language}}==
<lang vedit>File_Open("unixdict.txt", BROWSE)
#1 = 2 // length of longest word found
Repeat (ALL) {
#2 = EOL_Pos-Cur_Pos // length of this word
if (#2 >= #1) {
#3 = 1 // flag: is ordered word
Char(1)
While (!At_EOL) {
if (Cur_Char < Cur_Char(-1)) {
#3 = 0 // not an ordered word
break
}
Char(1)
}
if (#3) { // ordered word found
if (#2 > #1) { // new longer word found
#1 = #2
Reg_Empty(10) // clear list
}
BOL Reg_Copy(10,1,APPEND) // add word to list
}
}
Line(1,ERRBREAK) // next word
}
Buf_Quit(OK) // close file
Reg_Type(10) // display results </lang>
 
<pre>abbott
accent
accept
access
accost
almost
bellow
billow
biopsy
chilly
choosy
choppy
effort
floppy
glossy
knotty </pre>
 
=={{header|VBScript}}==
Line 4,226 ⟶ 4,187:
glossy
knotty</pre>
 
=={{header|Vedit macro language}}==
<lang vedit>File_Open("unixdict.txt", BROWSE)
#1 = 2 // length of longest word found
Repeat (ALL) {
#2 = EOL_Pos-Cur_Pos // length of this word
if (#2 >= #1) {
#3 = 1 // flag: is ordered word
Char(1)
While (!At_EOL) {
if (Cur_Char < Cur_Char(-1)) {
#3 = 0 // not an ordered word
break
}
Char(1)
}
if (#3) { // ordered word found
if (#2 > #1) { // new longer word found
#1 = #2
Reg_Empty(10) // clear list
}
BOL Reg_Copy(10,1,APPEND) // add word to list
}
}
Line(1,ERRBREAK) // next word
}
Buf_Quit(OK) // close file
Reg_Type(10) // display results </lang>
 
<pre>abbott
accent
accept
access
accost
almost
bellow
billow
biopsy
chilly
choosy
choppy
effort
floppy
glossy
knotty </pre>
 
=={{header|zkl}}==
10,333

edits