MAC vendor lookup: Difference between revisions
Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Ada version) |
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
||
Line 76:
{{out}}
<pre>Hon Hai Precision Ind. Co.,Ltd.</pre>
=={{header|C}}==
Line 209 ⟶ 208:
(error "~%Not a MAC address: ~a" mac))))
</lang>
=={{header|Free Pascal}}==
Line 396 ⟶ 394:
}
}</lang>
=={{header|Javascript}}==
Line 409 ⟶ 406:
{{out}}
<pre>Intel Corporate</pre>
=={{header|Julia}}==
Line 470 ⟶ 465:
local macAddress = "FC-A1-3E-2A-1C-33"
print(lookup(macAddress))</lang>
=={{header|M2000 Interpreter}}==
<lang M2000 Interpreter>
Line 497 ⟶ 493:
Checkit
</lang>
=={{header|Mathematica}}==
<lang Mathematica>macLookup[mac_String] := Quiet[Check[Import["http://api.macvendors.com/" <> mac], "N/A"]]</lang>
Line 594 ⟶ 591:
FC:FB:FB:01:FA:21 = Cisco Systems, Inc
BC:5F:F4 = ASRock Incorporation</pre>
=={{header|Perl 6}}==▼
{{works with|Rakudo|2018.03}}▼
Apparently there is some rate limiting on place now, sleep a bit between requests.▼
<lang perl6>use HTTP::UserAgent;▼
my $ua = HTTP::UserAgent.new;▼
$ua.timeout = 10; # seconds▼
my $server = 'http://api.macvendors.com/';▼
sub lookup ($mac) {▼
my $response = $ua.get: "$server+$mac";▼
sleep 1;▼
return $response.is-success ?? $response.content !! 'N/A';▼
CATCH { # Normally you would report some information about what▼
default { Nil } # went wrong, but the task specifies to ignore errors.▼
}▼
}▼
for <▼
BC:5F:F4▼
FC-A1-3E▼
10:dd:b1▼
00:0d:4b▼
23:45:67▼
> -> $mac { say lookup $mac }</lang>▼
{{out}}▼
<pre>ASRock Incorporation▼
Samsung Electronics Co.,Ltd▼
Apple, Inc.▼
Roku, Inc.▼
N/A▼
</pre>▼
=={{header|Phix}}==
Line 706 ⟶ 666:
FC:FB:FB:01:FA:21 Cisco Systems, Inc
D4:F4:6F:C9:EF:8D Apple, Inc.</pre>
(formerly Perl 6)
▲{{works with|Rakudo|2018.03}}
▲Apparently there is some rate limiting on place now, sleep a bit between requests.
▲<lang perl6>use HTTP::UserAgent;
▲my $ua = HTTP::UserAgent.new;
▲$ua.timeout = 10; # seconds
▲my $server = 'http://api.macvendors.com/';
▲sub lookup ($mac) {
▲ my $response = $ua.get: "$server+$mac";
▲ sleep 1;
▲ return $response.is-success ?? $response.content !! 'N/A';
▲ CATCH { # Normally you would report some information about what
▲ default { Nil } # went wrong, but the task specifies to ignore errors.
▲ }
▲}
▲for <
▲BC:5F:F4
▲FC-A1-3E
▲10:dd:b1
▲00:0d:4b
▲23:45:67
▲> -> $mac { say lookup $mac }</lang>
▲{{out}}
▲<pre>ASRock Incorporation
▲Samsung Electronics Co.,Ltd
▲Apple, Inc.
▲Roku, Inc.
▲N/A
▲</pre>
=={{header|Ring}}==
Line 744 ⟶ 742:
23:45:67 Vendor not found
</pre>
=={{header|Rust}}==
Line 806 ⟶ 803:
N/A
</pre>
=={{header|Scala}}==
<lang scala>object LookUp extends App {
Line 815 ⟶ 813:
macs.foreach(mac => println(lookupVendor(mac)))
}</lang>
=={{header|Tcl}}==
<lang Tcl>package require http
|