MAC vendor lookup: Difference between revisions

Content added Content deleted
(→‎{{header|APL}}: Add implementation.)
Line 74: Line 74:
vendorLookup1 ← { (HttpCommand.Get 'http://api.macvendors.com/',⍕⍵).Data }
vendorLookup1 ← { (HttpCommand.Get 'http://api.macvendors.com/',⍕⍵).Data }


⍝ define a traditional function to look up all the MAC addresses on a list with
⍝ define a traditional function to look up all the MAC addresses in a list with
⍝ a delay between calls
⍝ a delay between calls


⍝ The header says that the function is named vendorLookup, it takes a single parameter
⍝ The header says that the function is named vendorLookup, it takes a single
called macList in the body, and the value of the local variable vendors will become
parameter which we call macList, and the value of the local variable
its return value
vendors will become the function's return value
∇ vendors ← vendorLookup macList
∇ vendors ← vendorLookup macList

vendors ← ⊆vendorLookup1 macList[1] ⍝ look up the first vendor
⍝ look up the first vendor and put it into an array in our return var
vendors ← ⊆vendorLookup1 macList[1]

⍝ Loop over the rest of the array (1↓ removes the first item)
:For burger :In 1↓macList
:For burger :In 1↓macList
⎕DL 2 wait 2 seconds
⎕DL 2 wait 2 seconds
vendors ⍪← ⊆vendorLookup burger. ⍝ look up the next vendor
vendors ⍪← ⊆vendorLookup1 burger then look up the next vendor and append to result
:EndFor
:EndFor
⍝ end function definition
⍝ end function definition</lang>

</lang>
{{Out}}
<pre> macList ← '88:53:2E:67:07:BE' 'D4:F4:6F:C9:EF:8D' 'FC:FB:FB:01:FA:21'
macList ⍪← '4c:72:b9:56:fe:bc' '00-14-22-01-23-45'

vendorList ← vendorLookup macList
(⍴ vendorList)[1] 1⍴ vendorList
Intel Corporate
Apple, Inc.
Cisco Systems, Inc
PEGATRON CORPORATION
Dell Inc.
</pre>


=={{header|AppleScript}}==
=={{header|AppleScript}}==