Dating agency: Difference between revisions

Content added Content deleted
(Added 11l)
m (syntax highlighting fixup automation)
Line 22: Line 22:
{{trans|Python}}
{{trans|Python}}


<lang 11l>V sailors = [‘Adrian’, ‘Caspian’, ‘Dune’, ‘Finn’, ‘Fisher’, ‘Heron’, ‘Kai’, ‘Ray’, ‘Sailor’, ‘Tao’]
<syntaxhighlight lang="11l">V sailors = [‘Adrian’, ‘Caspian’, ‘Dune’, ‘Finn’, ‘Fisher’, ‘Heron’, ‘Kai’, ‘Ray’, ‘Sailor’, ‘Tao’]


V ladies = [‘Ariel’, ‘Bertha’, ‘Blue’, ‘Cali’, ‘Catalina’, ‘Gale’, ‘Hannah’, ‘Isla’, ‘Marina’, ‘Shelly’]
V ladies = [‘Ariel’, ‘Bertha’, ‘Blue’, ‘Cali’, ‘Catalina’, ‘Gale’, ‘Hannah’, ‘Isla’, ‘Marina’, ‘Shelly’]
Line 39: Line 39:
print(‘ Sailor ’sailor‘ should take an offer to date her.’)
print(‘ Sailor ’sailor‘ should take an offer to date her.’)
E
E
print(‘Dating service should NOT offer a date with ’lady)</lang>
print(‘Dating service should NOT offer a date with ’lady)</syntaxhighlight>


{{out}}
{{out}}
Line 71: Line 71:
=={{header|Factor}}==
=={{header|Factor}}==
{{works with|Factor|0.99 2021-06-02}}
{{works with|Factor|0.99 2021-06-02}}
<lang factor>USING: formatting io kernel math math.primes math.vectors
<syntaxhighlight lang="factor">USING: formatting io kernel math math.primes math.vectors
prettyprint qw sequences sets ;
prettyprint qw sequences sets ;


Line 104: Line 104:
lovable ladies. nl
lovable ladies. nl
sailor "But just between us, only the following ladies are compatible with %s:\n" printf
sailor "But just between us, only the following ladies are compatible with %s:\n" printf
compatible ladies.</lang>
compatible ladies.</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 134: Line 134:
=={{header|Julia}}==
=={{header|Julia}}==
{{trans|Python}}
{{trans|Python}}
<lang julia>sailors = ["Adrian", "Caspian", "Dune", "Finn", "Fisher", "Heron", "Kai",
<syntaxhighlight lang="julia">sailors = ["Adrian", "Caspian", "Dune", "Finn", "Fisher", "Heron", "Kai",
"Ray", "Sailor", "Tao"]
"Ray", "Sailor", "Tao"]


Line 156: Line 156:
end
end
end
end
</lang>{{out}}
</syntaxhighlight>{{out}}
<pre>
<pre>
Dating service should NOT offer a date with Ariel
Dating service should NOT offer a date with Ariel
Line 186: Line 186:
=={{header|Perl}}==
=={{header|Perl}}==
{{trans|Raku}}
{{trans|Raku}}
<lang perl>use strict;
<syntaxhighlight lang="perl">use strict;
use warnings;
use warnings;


Line 219: Line 219:
$matches{$_} < $max or $max = $matches{$_} for keys %matches;
$matches{$_} < $max or $max = $matches{$_} for keys %matches;
print 'Best match(s): ' . join(', ', sort grep { $matches{$_} == $max } keys %matches) . "\n\n";
print 'Best match(s): ' . join(', ', sort grep { $matches{$_} == $max } keys %matches) . "\n\n";
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>Elizabeth will like: Adam, Conrad, Ian, Jake, Larry, Bob, Drew, Quincy, Mike, Victor
<pre>Elizabeth will like: Adam, Conrad, Ian, Jake, Larry, Bob, Drew, Quincy, Mike, Victor
Line 247: Line 247:
Booleans in Phix are just integers, and need to be printed with %t rather than %s.
Booleans in Phix are just integers, and need to be printed with %t rather than %s.
Of course all this is open source, yada-yada-ya.
Of course all this is open source, yada-yada-ya.
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">without</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">without</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">structs</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">structs</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 318: Line 318:
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\nand %s should offer to date these ones:\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">sailor</span><span style="color: #0000FF;">.</span><span style="color: #000000;">name</span><span style="color: #0000FF;">})</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\nand %s should offer to date these ones:\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">sailor</span><span style="color: #0000FF;">.</span><span style="color: #000000;">name</span><span style="color: #0000FF;">})</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">lady_names</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">filter</span><span style="color: #0000FF;">(</span><span style="color: #000000;">eligibles</span><span style="color: #0000FF;">,</span><span style="color: #000000;">sailor_love</span><span style="color: #0000FF;">)))</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">lady_names</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">filter</span><span style="color: #0000FF;">(</span><span style="color: #000000;">eligibles</span><span style="color: #0000FF;">,</span><span style="color: #000000;">sailor_love</span><span style="color: #0000FF;">)))</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 344: Line 344:


=={{header|Python}}==
=={{header|Python}}==
<lang python>"""
<syntaxhighlight lang="python">"""
Jokes about courtesans aside, the selection process is by the letters of the names.
Jokes about courtesans aside, the selection process is by the letters of the names.
If the integer corresponding to the ASCII character of the first letter of the
If the integer corresponding to the ASCII character of the first letter of the
Line 372: Line 372:
else:
else:
print("Dating service should NOT offer a date with", lady)
print("Dating service should NOT offer a date with", lady)
</lang>{{out}}
</syntaxhighlight>{{out}}
<pre>
<pre>
Dating service should NOT offer a date with Ariel
Dating service should NOT offer a date with Ariel
Line 403: Line 403:
Welcome to the '''Arbitrary and Capricious Dating Agency''', (We don't use zodiacs, but we're just as arbitrary!)
Welcome to the '''Arbitrary and Capricious Dating Agency''', (We don't use zodiacs, but we're just as arbitrary!)


<lang perl6>use Digest::SHA1::Native;
<syntaxhighlight lang="raku" line>use Digest::SHA1::Native;


my %ladies = < Alice Beth Cecilia Donna Eunice Fran Genevieve Holly Irene Josephine Kathlene Loralie Margaret
my %ladies = < Alice Beth Cecilia Donna Eunice Fran Genevieve Holly Irene Josephine Kathlene Loralie Margaret
Line 430: Line 430:
say 'Best match(s): ' ~ %matches.grep(*.value == %matches.values.max)».key.sort.join(', ');
say 'Best match(s): ' ~ %matches.grep(*.value == %matches.values.max)».key.sort.join(', ');
say '';
say '';
}</lang>
}</syntaxhighlight>


<pre> Ahab will like: Eunice, Ursula, Irene, Holly, Fran, Genevieve, Zoey, Donna, Cecilia, Alice
<pre> Ahab will like: Eunice, Ursula, Irene, Holly, Fran, Genevieve, Zoey, Donna, Cecilia, Alice
Line 447: Line 447:
{{libheader|Wren-math}}
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
{{libheader|Wren-fmt}}
<lang ecmascript>import "./math" for Int, Nums
<syntaxhighlight lang="ecmascript">import "./math" for Int, Nums
import "./fmt" for Fmt
import "./fmt" for Fmt


Line 510: Line 510:
System.print(eligibles)
System.print(eligibles)
System.print("\nand %(sailor) should offer to date these ones:")
System.print("\nand %(sailor) should offer to date these ones:")
System.print(eligibles.where { |e| sailor.love(e) }.toList)</lang>
System.print(eligibles.where { |e| sailor.love(e) }.toList)</syntaxhighlight>


{{out}}
{{out}}