task_url stringlengths 30 116 | task_name stringlengths 2 86 | task_description stringlengths 0 14.4k | language_url stringlengths 2 53 | language_name stringlengths 1 52 | code stringlengths 0 61.9k |
|---|---|---|---|---|---|
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #AppleScript | AppleScript |
set {table, macList} to {{return}, {"88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D", "FC:FB:FB:01:FA:21", "4c:72:b9:56:fe:bc", "00-14-22-01-23-45"}}
repeat with burger in macList
set end of table to do shell script "curl http://api.macvendors.com/" & burger & " && sleep 5 && echo '\n'" & return
end repeat
return table ... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Arturo | Arturo | loop ["FC-A1-3E" "FC:FB:FB:01:FA:21" "BC:5F:F4"] 'mac [
print [mac "=>" read ~"http://api.macvendors.com/|mac|"]
pause 1500
] |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #Octave | Octave | #! /usr/bin/octave -qf
global width = 200;
global height = 200;
maxiter = 100;
z0 = 0;
global cmax = 1 + i;
global cmin = -2 - i;
function cs = pscale(c)
global cmax;
global cmin;
global width;
global height;
persistent px = (real(cmax-cmin))/width;
persistent py = (imag(cmax-cmin))/height;
cs = real(... |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #Rascal | Rascal | public rel[real, real, real] matrixMultiplication(rel[real x, real y, real v] matrix1, rel[real x, real y, real v] matrix2){
if (max(matrix1.x) == max(matrix2.y)){
p = {<x1,y1,x2,y2, v1*v2> | <x1,y1,v1> <- matrix1, <x2,y2,v2> <- matrix2};
result = {};
for (y <- matrix1.y){
for (x <- matrix2.x){
v = (0.0... |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Rascal | Rascal | public rel[real, real, real] matrixTranspose(rel[real x, real y, real v] matrix){
return {<y, x, v> | <x, y, v> <- matrix};
}
//a matrix
public rel[real x, real y, real v] matrixA = {
<0.0,0.0,12.0>, <0.0,1.0, 6.0>, <0.0,2.0,-4.0>,
<1.0,0.0,-51.0>, <1.0,1.0,167.0>, <1.0,2.0,24.0>,
<2.0,0.0,4.0>, <2.0,1.0,-68.0>... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #AutoHotkey | AutoHotkey | macLookup(MAC){
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("GET", "http://api.macvendors.com/" MAC)
WebRequest.Send()
return WebRequest.ResponseText
} |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #BaCon | BaCon | OPTION TLS TRUE
website$ = "api.macvendors.com"
mac$ = "b0:52:16:d0:3c:fb"
OPEN website$ & ":443" FOR NETWORK AS mynet
SEND "GET /" & mac$ & " HTTP/1.1\r\nHost: " & website$ & "\r\n\r\n" TO mynet
RECEIVE info$ FROM mynet
CLOSE NETWORK mynet
PRINT TOKEN$(info$, 2, "\r\n\r\n") |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #Ol | Ol |
(define x-size 59)
(define y-size 21)
(define min-im -1)
(define max-im 1)
(define min-re -2)
(define max-re 1)
(define step-x (/ (- max-re min-re) x-size))
(define step-y (/ (- max-im min-im) y-size))
(for-each (lambda (y)
(let ((im (+ min-im (* step-y y))))
(for-each (lambda (x)
(let*... |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #REXX | REXX | /*REXX program multiplies two matrices together, displays the matrices and the results. */
x.=; x.1= 1 2 /*╔═══════════════════════════════════╗*/
x.2= 3 4 /*║ As none of the matrix values have ║*/
x.3= 5 6 ... |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #REXX | REXX | /*REXX program transposes any sized rectangular matrix, displays before & after matrices*/
@.=; @.1 = 1.02 2.03 3.04 4.05 5.06 6.07 7.08
@.2 = 111 2222 33333 444444 5555555 66666666 777777777
w=0
do row=1 whil... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #C | C |
#include <curl/curl.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
/* Length of http://api.macvendors.com/ */
#define FIXED_LENGTH 16
struct MemoryStruct {
char *memory;
size_t size;
};
static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
size_t realsi... |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #OpenEdge.2FProgress | OpenEdge/Progress | DEFINE VARIABLE print_str AS CHAR NO-UNDO INIT ''.
DEFINE VARIABLE X1 AS DECIMAL NO-UNDO INIT 50.
DEFINE VARIABLE Y1 AS DECIMAL NO-UNDO INIT 21.
DEFINE VARIABLE X AS DECIMAL NO-UNDO.
DEFINE VARIABLE Y AS DECIMAL NO-UNDO.
DEFINE VARIABLE N AS DECIMAL NO-UNDO.
DEFINE VARIABLE I3 AS DECIMAL NO-UNDO.
DEFINE VARIABLE R3 AS ... |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #Ring | Ring |
load "stdlib.ring"
n = 3
C = newlist(n,n)
A = [[1,2,3], [4,5,6], [7,8,9]]
B = [[1,0,0], [0,1,0], [0,0,1]]
for i = 1 to n
for j = 1 to n
for k = 1 to n
C[i][k] += A[i][j] * B[j][k]
next
next
next
for i = 1 to n
for j = 1 to n
see C[i][j] + " "
next
see nl
next
|
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Ring | Ring |
load "stdlib.ring"
transpose = newlist(5,4)
matrix = [[78,19,30,12,36], [49,10,65,42,50], [30,93,24,78,10], [39,68,27,64,29]]
for i = 1 to 5
for j = 1 to 4
transpose[i][j] = matrix[j][i]
see "" + transpose[i][j] + " "
next
see nl
next
|
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #C.23 | C# | using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task<string> LookupMac(string MacAddress)
{
var uri = new Uri("http://api.macvendors.com/" + WebUtility.UrlEncode(MacAddress));
using (var wc = new HttpClient())
return... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #C.2B.2B | C++ | // This code is based on the example 'Simple HTTP Client' included with
// the Boost documentation.
#include <boost/beast/core.hpp>
#include <boost/beast/http.hpp>
#include <boost/beast/version.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <iostream>
#include <string>
bool get_mac... |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #PARI.2FGP | PARI/GP | mandelbrot() =
{
forstep(y=-1, 1, 0.05,
forstep(x=-2, 0.5, 0.0315,
print1(((c)->my(z=c);for(i=1,20,z=z*z+c;if(abs(z)>2,return(" ")));"#")(x+y*I)));
print());
} |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #Ruby | Ruby | require 'matrix'
Matrix[[1, 2],
[3, 4]] * Matrix[[-3, -8, 3],
[-2, 1, 4]] |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #RLaB | RLaB | >> m = rand(3,5)
0.41844289 0.476591435 0.75054022 0.226388925 0.963880314
0.91267171 0.941762397 0.464227895 0.693482786 0.203839405
0.261512966 0.157981873 0.26582235 0.11557427 0.0442493069
>> m'
0.41844289 0.91267171 0.261512966
0.476591435 0.941762397 0.157981873
0.750... |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Ruby | Ruby | m=[[1, 1, 1, 1],
[2, 4, 8, 16],
[3, 9, 27, 81],
[4, 16, 64, 256],
[5, 25,125, 625]]
puts m.transpose |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Common_Lisp | Common Lisp | (quicklisp:quickload :Drakma) ; or load it in another way
(defun mac-vendor (mac)
(check-type mac string "A MAC address as a string")
(multiple-value-bind (vendor status)
(drakma:http-request (format nil "http://api.macvendors.com/~a" mac))
(if (= 200 status)
(format t "~%Vendor is ~a" ve... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Delphi | Delphi |
program MAC_Vendor_Lookup;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
IdHttp;
function macLookUp(mac: string): string;
begin
Result := '';
with TIdHTTP.Create(nil) do
begin
try
Result := Get('http://api.macvendors.com/' + mac);
except
on E: Exception do
Writeln(e.Message);
... |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #Pascal | Pascal | program mandelbrot;
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
const
ixmax = 800;
iymax = 800;
cxmin = -2.5;
cxmax = 1.5;
cymin = -2.0;
cymax = 2.0;
maxcolorcomponentvalue = 255;
maxiteration = 200;
escaperadius = 2;
type
colortype = record
red : byte;
green : b... |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #Rust | Rust |
struct Matrix {
dat: [[f32; 3]; 3]
}
impl Matrix {
pub fn mult_m(a: Matrix, b: Matrix) -> Matrix
{
let mut out = Matrix {
dat: [[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]
]
};
for i in 0..3{
for j in 0.... |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Run_BASIC | Run BASIC | mtrx$ ="4, 3, 0, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.00, 1.10"
print "Transpose of matrix"
call DisplayMatrix mtrx$
print " ="
MatrixT$ =MatrixTranspose$(mtrx$)
call DisplayMatrix MatrixT$
end
function MatrixTranspose$(in$)
w = val(word$(in$, 1, ",")) ' swap w and h paramet... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Factor | Factor | USING: accessors calendar continuations http.client io kernel
sequences threads ;
: mac-vendor ( str -- str )
"http://api.macvendors.com/" prepend
[ http-get nip ] [ nip response>> message>> ] recover ;
"FC-A1-3E"
"FC:FB:FB:01:FA:21"
"10-11-22-33-44-55-66"
[ mac-vendor print 1 seconds sleep ] tri@ |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #FreeBASIC | FreeBASIC | Function pipeout(Byval s As String = "") Byref As String
Var f = Freefile
Dim As String tmp
Open Pipe s For Input As #f
s = ""
Do Until Eof(f)
Line Input #f, tmp
s &= tmp
Loop
Close #f
Return s
End Function
Function lookupvendor(webpage As String, mac As String) As St... |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #Perl | Perl | use Math::Complex;
sub mandelbrot {
my ($z, $c) = @_[0,0];
for (1 .. 20) {
$z = $z * $z + $c;
return $_ if abs $z > 2;
}
}
for (my $y = 1; $y >= -1; $y -= 0.05) {
for (my $x = -2; $x <= 0.5; $x += 0.0315)
{print mandelbrot($x + $y * i) ? ' ' : '#'}
print "\n"
} |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #S-lang | S-lang | % Matrix multiplication is a built-in with the S-Lang octothorpe operator.
variable A = [1,2,3,4,5,6];
reshape(A, [2,3]); % reshape 1d array to 2 rows, 3 columns
printf("A is %S\n", A); print(A);
variable B = [1:6]; % index range, 1 to 6 same as above in A
reshape(B, [3,2]); % resha... |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Rust | Rust |
struct Matrix {
dat: [[i32; 3]; 3]
}
impl Matrix {
pub fn transpose_m(a: Matrix) -> Matrix
{
let mut out = Matrix {
dat: [[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
]
};
for i in 0..3{
for j in 0..3{
... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Free_Pascal | Free Pascal | program MACVendorLookup;
uses
fphttpclient;
var
res: String;
begin
if paramCount > 0 then begin
With TFPHttpClient.Create(Nil) do
try
allowRedirect := true;
try
res := Get('http://api.macvendors.com/' + ParamStr(1));
writeLn(res);
except
writeLn('N/A');
... |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #6502_Assembly | 6502 Assembly | LDA #$07
CLC
ADC #$0C
RTS |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #Phix | Phix | --
-- Mandlebrot set in ascii art demo.
--
constant b=" .:,;!/>)|&IH%*#"
atom r, i, c, C, z, Z, t, k
for y=30 to 0 by -1 do
C = y*0.1-1.5
puts(1,'\n')
for x=0 to 74 do
c = x*0.04-2
z = 0
Z = 0
r = c
i = C
k = 0
... |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #Scala | Scala | def mult[A](a: Array[Array[A]], b: Array[Array[A]])(implicit n: Numeric[A]) = {
import n._
for (row <- a)
yield for(col <- b.transpose)
yield row zip col map Function.tupled(_*_) reduceLeft (_+_)
} |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Scala | Scala | scala> Array.tabulate(4)(i => Array.tabulate(4)(j => i*4 + j))
res12: Array[Array[Int]] = Array(Array(0, 1, 2, 3), Array(4, 5, 6, 7), Array(8, 9, 10, 11), Array(12, 13, 14, 15))
scala> res12.transpose
res13: Array[Array[Int]] = Array(Array(0, 4, 8, 12), Array(1, 5, 9, 13), Array(2, 6, 10, 14), Array(3, 7, 11, 15))
... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Go | Go | package main
import (
"net/http"
"fmt"
"io/ioutil"
)
func macLookUp(mac string) (res string){
resp, _ := http.Get("http://api.macvendors.com/" + mac)
body, _ := ioutil.ReadAll(resp.Body)
res = string(body)
return
}
func main() {
fmt.Println(macLookUp("FC-A1-3E"))
fmt.Println(macLookUp("FC:FB:FB:01:FA:21... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Haskell | Haskell | #!/usr/bin/env stack
{- stack
script
--resolver lts-9.0
--package bytestring
--package http-client
--package http-types
-}
{-# LANGUAGE MultiWayIf #-}
import Control.Exception (try)
import Control.Monad (forM_)
import qualified Data.ByteString.Lazy.Char8 as L8 (ByteString, unpack)
import Network.HTTP.Clie... |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #68000_Assembly | 68000 Assembly | MOVE.B #7,D0
ADD.B #12,D0
RTS |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #Action.21 | Action! | DEFINE ADC="$6D"
DEFINE CLC="$18"
DEFINE JSR="$20"
DEFINE LDA="$AD"
DEFINE RTS="$60"
DEFINE STA="$8D"
PROC Main()
BYTE ARRAY buf(20)
BYTE a=[19],b=[37],s
CARD addr
addr=buf
Poke(addr,CLC) addr==+1
Poke(addr,LDA) addr==+1
PokeC(addr,@a) addr==+2
Poke(addr,ADC) addr==+1
PokeC(addr,@b) addr==+2
Pok... |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #PHP | PHP | $min_x=-2;
$max_x=1;
$min_y=-1;
$max_y=1;
$dim_x=400;
$dim_y=300;
$im = @imagecreate($dim_x, $dim_y)
or die("Cannot Initialize new GD image stream");
header("Content-Type: image/png");
$black_color = imagecolorallocate($im, 0, 0, 0);
$white_color = imagecolorallocate($im, 255, 255, 255);
for($y=0;$y<=$dim_y;$y+... |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #Scheme | Scheme | (define (matrix-multiply matrix1 matrix2)
(map
(lambda (row)
(apply map
(lambda column
(apply + (map * row column)))
matrix2))
matrix1)) |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Scheme | Scheme | (define (transpose m)
(apply map list m)) |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Seed7 | Seed7 | $ include "seed7_05.s7i";
include "float.s7i";
const type: matrix is array array float;
const func matrix: transpose (in matrix: aMatrix) is func
result
var matrix: transposedMatrix is matrix.value;
local
var integer: i is 0;
var integer: j is 0;
begin
transposedMatrix := length(aMatrix[1]) ... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #J | J | require 'web/gethttp'
lookupMACvendor=: [: gethttp 'http://api.macvendors.com/'&, |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Java | Java | package com.jamesdonnell.MACVendor;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
/** MAC Vendor Lookup class.
* www.JamesDonnell.com
* @author James A. Donnell Jr. */
publi... |
http://rosettacode.org/wiki/Magic_8-ball | Magic 8-ball | Task
Create Magic 8-Ball.
See details at: Magic 8-Ball.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioinformatics/base count
Count occurren... | #11l | 11l | V s = [‘It is certain’, ‘It is decidedly so’, ‘Without a doubt’, ‘Yes, definitely’,
‘You may rely on it’, ‘As I see it, yes’, ‘Most likely’, ‘Outlook good’,
‘Signs point to yes’, ‘Yes’, ‘Reply hazy, try again’, ‘Ask again later’,
‘Better not tell you now’, ‘Cannot predict now’, ‘Concentrate and ask again’,
‘Don't b... |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #Applesoft_BASIC | Applesoft BASIC | POKE768,169:POKE770,24:POKE771,105:POKE773,133:POKE775,96:POKE774,235:POKE769,7:POKE772,12:CALL768:?PEEK(235) |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #AutoHotkey | AutoHotkey | MCode(Var, "8B44240403442408C3")
MsgBox, % DllCall(&Var, "Char",7, "Char",12)
Var := ""
return
; http://www.autohotkey.com/board/topic/19483-machine-code-functions-bit-wizardry/
MCode(ByRef code, hex) { ; allocate memory and write Machine Code there
VarSetCapacity(code, StrLen(hex) // 2)
Loop % StrLen(hex) // 2... |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #Picat | Picat | go =>
Width = 90,
Height = 50,
Limit = 50,
foreach(Y in 1..Height)
P="",
foreach (X in 1..Width)
Z=complex(0,0),
C=complex(2.5*X/Width-2.0,2.0*Y/Height-1.0),
J = 0,
while (J < Limit, c_abs(Z)<2.0)
Z := c_add(c_mul(Z,Z),C),
J := J +... |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #Seed7 | Seed7 | const type: matrix is array array float;
const func matrix: (in matrix: left) * (in matrix: right) is func
result
var matrix: result is matrix.value;
local
var integer: i is 0;
var integer: j is 0;
var integer: k is 0;
var float: accumulator is 0.0;
begin
if length(left[1]) <> length(rig... |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Sidef | Sidef | func transpose(matrix) {
matrix[0].range.map{|i| matrix.map{_[i]}};
};
var m = [
[1, 1, 1, 1],
[2, 4, 8, 16],
[3, 9, 27, 81],
[4, 16, 64, 256],
[5, 25, 125, 625],
];
transpose(m).each { |row|
"%5d" * row.len -> printlnf(row...);
} |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #JavaScript | JavaScript |
var mac = "88:53:2E:67:07:BE";
function findmac(){
window.open("http://api.macvendors.com/" + mac);
}
findmac();
|
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Julia | Julia | # v0.6.0
using Requests
function getvendor(addr::String)
try
get("http://api.macvendors.com/$addr") |> readstring
catch e
nothing
end
end
for addr in ["88:53:2E:67:07:BE", "FC:FB:FB:01:FA:21", "D4:F4:6F:C9:EF:8D", "23:45:67"]
println("$addr -> ", getvendor(addr))
end |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Kotlin | Kotlin | // version 1.1.2
import java.net.URL
fun lookupVendor(mac: String) = URL("http://api.macvendors.com/" + mac).readText()
fun main(args: Array<String>) {
val macs = arrayOf("FC-A1-3E", "FC:FB:FB:01:FA:21", "88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D")
for (mac in macs) println(lookupVendor(mac))
} |
http://rosettacode.org/wiki/Magic_8-ball | Magic 8-ball | Task
Create Magic 8-Ball.
See details at: Magic 8-Ball.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioinformatics/base count
Count occurren... | #8080_Assembly | 8080 Assembly | bdos: equ 5 ; CP/M calls
puts: equ 9
gets: equ 10
org 100h
lxi d,message ; Print message
mvi c,puts
call bdos
question: lxi d,prompt ; Ask for question
mvi c,puts
call bdos
lxi d,bufdef ; Read answer
mvi c,gets
call bdos
lxi d,newline ; Print newline
mvi c,puts
call bdos
lxi h,buf ; XOR... |
http://rosettacode.org/wiki/Magic_8-ball | Magic 8-ball | Task
Create Magic 8-Ball.
See details at: Magic 8-Ball.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioinformatics/base count
Count occurren... | #8086_Assembly | 8086 Assembly |
.model small
.stack 1024
.data
UserRam BYTE 256 DUP(0)
xorshift32_state_lo equ UserRam
xorshift32_state_hi equ UserRam+2
Ans0 byte "It is certain.",0
Ans1 byte "It is decidedly so.",0
Ans2 byte "Signs point to yes.",0
Ans3 byte "You can rely on it.",0
Ans4 byte "Most likely.",0
Ans5 byte "Cannot predict now.",0
A... |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #BBC_BASIC | BBC BASIC | REM Claim 9 bytes of memory
SYS "GlobalAlloc",0,9 TO code%
REM Poke machine code into it
P%=code%
[OPT 0
mov EAX, [ESP+4]
add EAX, [ESP+8]
ret
]
REM Run code
SYS code%,7,12 TO result%
PRINT result%
REM Free memory
SYS "GlobalFree"... |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #C | C | #include <stdio.h>
#include <sys/mman.h>
#include <string.h>
int test (int a, int b)
{
/*
mov EAX, [ESP+4]
add EAX, [ESP+8]
ret
*/
char code[] = {0x8B, 0x44, 0x24, 0x4, 0x3, 0x44, 0x24, 0x8, 0xC3};
void *buf;
int c;
/* copy code to executable buffer */
buf = mmap (0,sizeof(code),PRO... |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #PicoLisp | PicoLisp | (scl 6)
(let Ppm (make (do 300 (link (need 400))))
(for (Y . Row) Ppm
(for (X . @) Row
(let (ZX 0 ZY 0 CX (*/ (- X 250) 1.0 150) CY (*/ (- Y 150) 1.0 150) C 570)
(while (and (> 4.0 (+ (*/ ZX ZX 1.0) (*/ ZY ZY 1.0))) (gt0 C))
(let Tmp (- (*/ ZX ZX 1.0) (*/ ZY ZY 1.0) (-... |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #SequenceL | SequenceL | matmul(A(2), B(2)) [i,j] :=
let k := 1...size(B);
in sum( A[i,k] * B[k,j] );
//Example Use
a := [[1, 2],
[3, 4]];
b := [[-3, -8, 3],
[-2, 1, 4]];
test := matmul(a, b); |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #SPAD | SPAD | (1) -> originalMatrix := matrix [[1, 1, 1, 1],[2, 4, 8, 16], _
[3, 9, 27, 81],[4, 16, 64, 256], _
[5, 25, 125, 625]]
+1 1 1 1 +
| |
|2 4 8 16 |
| |
(1) |3 9 27 81 |
... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Lua | Lua | -- Requires LuaSocket extension by Lua
-- Created by James A. Donnell Jr.
-- www.JamesDonnell.com
local baseURL = "http://api.macvendors.com/"
local function lookup(macAddress)
http = require "socket.http"
result, statuscode, content = http.request(baseURL .. macAddress)
return result
end
local macAddress = "F... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #M2000_Interpreter | M2000 Interpreter |
Module Checkit {
httpGet$=lambda$ (url$, timeout=500)->{
declare htmldoc "WinHttp.WinHttpRequest.5.1"
Method htmldoc "SetTimeouts", timeout, timeout, timeout, timeout
Method htmldoc "open","GET", url$, false
Method htmldoc "setRequestHeader","Content-Type", "appl... |
http://rosettacode.org/wiki/Magic_8-ball | Magic 8-ball | Task
Create Magic 8-Ball.
See details at: Magic 8-Ball.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioinformatics/base count
Count occurren... | #Action.21 | Action! | PROC Main()
DEFINE PTR="CARD"
DEFINE COUNT="20"
CHAR ARRAY s(256)
PTR ARRAY a(COUNT)
BYTE i
a(0)="It is certain."
a(1)="It is decidedly so."
a(2)="Without a doubt."
a(3)="Yes - definitely."
a(4)="You may rely on it."
a(5)="As I see it, yes."
a(6)="Most likely."
a(7)="Outlook good."
a(8)="Y... |
http://rosettacode.org/wiki/Magic_8-ball | Magic 8-ball | Task
Create Magic 8-Ball.
See details at: Magic 8-Ball.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioinformatics/base count
Count occurren... | #Ada | Ada |
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Numerics.Discrete_Random;
procedure Main is
--Creation of type with all the possible answers
--
type Possible_Answers_Type is (It_Is_Certain, It_Is_Decidedly_So, Without_A_Doubt,
Yes_Definitely, You_May_Rely_On_It... |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #COBOL | COBOL | pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl -0x4(%rbp), %esi
addl -0x8(%rbp), %esi
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %eax
popq %rbp
retq
|
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #Commodore_BASIC | Commodore BASIC | Assembly Hexadecimal Decimal
CLC 18 24
LDA $2000 AD 00 20 173 0 32
ADC $2001 6D 01 20 109 1 32
STA $2002 8D 02 20 141 2 32
RTS 60 96 |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #PostScript | PostScript | %!PS-Adobe-2.0
%%BoundingBox: 0 0 300 200
%%EndComments
/origstate save def
/ld {load def} bind def
/m /moveto ld /g /setgray ld
/dot { currentpoint 1 0 360 arc fill } bind def
%%EndProlog
% param
/maxiter 200 def
% complex manipulation
/complex { 2 array astore } def
/real { 0 get } def
/imag { 1 get } def
/cmul { /a ... |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #Sidef | Sidef | func matrix_multi(a, b) {
var m = [[]]
for r in ^a {
for c in ^b[0] {
for i in ^b {
m[r][c] := 0 += (a[r][i] * b[i][c])
}
}
}
return m
}
var a = [
[1, 2],
[3, 4],
[5, 6],
[7, 8]
]
var b = [
... |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Sparkling | Sparkling | function transpose(A) {
return map(range(sizeof A), function(k, idx) {
return map(A, function(k, row) {
return row[idx];
});
});
} |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Stata | Stata | . mat a=1,2,3\4,5,6
. mat b=a'
. mat list a
a[2,3]
c1 c2 c3
r1 1 2 3
r2 4 5 6
. mat list b
b[3,2]
r1 r2
c1 1 4
c2 2 5
c3 3 6 |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Mathematica.2FWolfram_Language | Mathematica/Wolfram Language | macLookup[mac_String] := Quiet[Check[Import["http://api.macvendors.com/" <> mac], "N/A"]] |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Nim | Nim | import httpclient
for mac in ["FC-A1-3E", "FC:FB:FB:01:FA:21", "BC:5F:F4"]:
echo newHttpClient().getContent("http://api.macvendors.com/"&mac) |
http://rosettacode.org/wiki/Magic_8-ball | Magic 8-ball | Task
Create Magic 8-Ball.
See details at: Magic 8-Ball.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioinformatics/base count
Count occurren... | #ALGOL_68 | ALGOL 68 | BEGIN
[]STRING answers = ("It is certain.", "It is decidedly so.",
"Without a doubt.", "Yes - definitely.", "You may rely on it.",
"As I see it, yes.", "Most likely.", "Outlook good.",
"Yes.", "Signs point to yes.", "Reply hazy, try again.",
... |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #Common_Lisp | Common Lisp | ;;Note that by using the 'CFFI' library, one can apply this procedure portably in any lisp implementation;
;; in this code however I chose to demonstrate only the implementation-dependent programs.
;;CCL
;; Allocate a memory pointer and poke the opcode into it
(defparameter ptr (ccl::malloc 9))
(loop for i in '(13... |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #PowerShell | PowerShell |
$x = $y = $i = $j = $r = -16
$colors = [Enum]::GetValues([System.ConsoleColor])
while(($y++) -lt 15)
{
for($x=0; ($x++) -lt 84; Write-Host " " -BackgroundColor ($colors[$k -band 15]) -NoNewline)
{
$i = $k = $r = 0
do
{
$j = $r * $r - $i * $i -2 + $x / 25
$i ... |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #SPAD | SPAD | (1) -> A:=matrix [[1,2],[3,4],[5,6],[7,8]]
+1 2+
| |
|3 4|
(1) | |
|5 6|
| |
+7 8+
Type: Matrix(Integer)
(2) -> B:=matrix [[1,2,3],[4,5,6]]
+1 2 3+
(2) | |
+4 5 6+
... |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Swift | Swift | @inlinable
public func matrixTranspose<T>(_ matrix: [[T]]) -> [[T]] {
guard !matrix.isEmpty else {
return []
}
var ret = Array(repeating: [T](), count: matrix[0].count)
for row in matrix {
for j in 0..<row.count {
ret[j].append(row[j])
}
}
return ret
}
@inlinable
public func printM... |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Tailspin | Tailspin |
templates transpose
def a: $;
[1..$a(1)::length -> $a(1..last;$)] !
end transpose
templates printMatrix&{w:}
templates formatN
@: [];
$ -> #
'$@ -> $::length~..$w -> ' ';$@(last..1:-1)...;' !
when <1..> do ..|@: $ mod 10; $ ~/ 10 -> #
end formatN
$... -> '|$(1) -> formatN;$(2..last)... -> ... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #OCaml | OCaml |
(* build with ocamlfind ocamlopt -package netclient -linkpkg macaddr.ml -o macaddr *)
open Printf
open Nethttp_client.Convenience
open Unix
(* example vendors, including a nonsense one *)
let vendors = ["FF:FF:FF:67:07:BE"; "D4:F4:6F:C9:EF:8D"; "FC:FB:FB:01:FA:21"; "88:53:2E:67:07:BE"]
let get_vendor addr =
... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Perl | Perl | #!/usr/bin/env perl -T
use 5.018_002;
use warnings;
use LWP;
our $VERSION = 1.000_000;
my $ua = LWP::UserAgent->new;
my @macs = (
'FC-A1-3EFC:FB:FB:01:FA:21', '00,0d,4b',
'Rhubarb', '00-14-22-01-23-45',
'10:dd:b1', 'D4:F4:6F:C9:EF:8D',
'FC-A1-3E', ... |
http://rosettacode.org/wiki/Magic_8-ball | Magic 8-ball | Task
Create Magic 8-Ball.
See details at: Magic 8-Ball.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioinformatics/base count
Count occurren... | #AppleScript | AppleScript | set the answers to {"It is certain", "It is decidedly so", "Without a doubt", "Yes, definitely", "You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Signs point to yes", "Yes", "Reply hazy, try again", "Ask again later", "Better not tell you now", "Cannot predict now", "Concentrate and ask again"... |
http://rosettacode.org/wiki/Magic_8-ball | Magic 8-ball | Task
Create Magic 8-Ball.
See details at: Magic 8-Ball.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioinformatics/base count
Count occurren... | #Arturo | Arturo | answers: [
"It is certain" "It is decidedly so" "Without a doubt"
"Yes, definitely" "You may rely on it" "As I see it, yes"
"Most likely" "Outlook good" "Signs point to yes" "Yes"
"Reply hazy, try again" "Ask again later"
"Better not tell you now" "Cannot predict now"
"Concentrate and ask again"... |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #Cowgol | Cowgol | include "cowgol.coh";
# Run machine code at cptr, given two 32-bit arguments,
# return the value returned from EAX.
sub RunCode(cptr: [uint8], arg1: uint32, arg2: uint32): (rslt: uint32) is
# Inline assembly is supported, so this whole rigmarole
# is not even necessary.
# Though note that this (obviousl... |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #D | D | int test(in int a, in int b) pure nothrow @nogc {
/*
mov EAX, [ESP+4]
add EAX, [ESP+8]
ret
*/
immutable ubyte[9] code = [0x8B, 0x44, 0x24, 0x4, 0x3, 0x44, 0x24, 0x8, 0xC3];
alias F = extern(C) int function(int, int) pure nothrow @nogc;
immutable f = cast(F)code.ptr;
return f(a, b); /... |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #Processing | Processing | double x, y, zr, zi, zr2, zi2, cr, ci, n;
double zmx1, zmx2, zmy1, zmy2, f, di, dj;
double fn1, fn2, fn3, re, gr, bl, xt, yt, i, j;
void setup() {
size(500, 500);
di = 0;
dj = 0;
f = 10;
fn1 = random(20);
fn2 = random(20);
fn3 = random(20);
zmx1 = int(width / 4);
zmx2 = 2;
zmy1 = int(height / 4)... |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #SQL | SQL | CREATE TABLE a (x INTEGER, y INTEGER, e REAL);
CREATE TABLE b (x INTEGER, y INTEGER, e REAL);
-- test data
-- A is a 2x2 matrix
INSERT INTO a VALUES(0,0,1); INSERT INTO a VALUES(1,0,2);
INSERT INTO a VALUES(0,1,3); INSERT INTO a VALUES(1,1,4);
-- B is a 2x3 matrix
INSERT INTO b VALUES(0,0,-3); INSERT INTO b VALUES(... |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #Tcl | Tcl | package require Tcl 8.5
namespace path ::tcl::mathfunc
proc size {m} {
set rows [llength $m]
set cols [llength [lindex $m 0]]
return [list $rows $cols]
}
proc transpose {m} {
lassign [size $m] rows cols
set new [lrepeat $cols [lrepeat $rows ""]]
for {set i 0} {$i < $rows} {incr i} {
f... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Phix | Phix | without js -- libcurl
string test = "00-11-22-33-44-55-66" -- CIMSYS Inc
--string test = "10-11-22-33-44-55-66" -- N/A
include builtins/libcurl.e
curl_global_init()
atom curl = curl_easy_init()
string url = sprintf("http://api.macvendors.com/%s",{test})
curl_easy_setopt(curl, CURLOPT_URL, url)
object res = cur... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #PicoLisp | PicoLisp | (load "@lib/http.l")
(de maclookup (M)
(client "api.macvendors.com" 80
M
(while (line))
(line T) ) )
(test
"Intel Corporate"
(maclookup "88:53:2E:67:07:BE") )
(test
"Apple, Inc."
(maclookup "D4:F4:6F:C9:EF:8D") ) |
http://rosettacode.org/wiki/Magic_8-ball | Magic 8-ball | Task
Create Magic 8-Ball.
See details at: Magic 8-Ball.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioinformatics/base count
Count occurren... | #AutoHotkey | AutoHotkey | answers := [
(join
"It is certain", "It is decidedly so", "Without a doubt","Yes, definitely",
"You may rely on it", "As I see it, yes","Most likely", "Outlook good",
"Signs point to yes", "Yes","Reply hazy, try again", "Ask again later",
"Better not tell you now", "Cannot predict now","Concentrate and ask again",
"Don... |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #Draco | Draco | /* 8080 machine code in an array */
[6] byte add_mc = (
0xC1, /* POP B - get return address */
0xD1, /* POP D - get second argument */
0xE1, /* POP H - get first argument */
0x19, /* DAD D - add arguments */
0xC5, /* PUSH B - push return address back... |
http://rosettacode.org/wiki/Machine_code | Machine code | The task requires poking machine code directly into memory and executing it. The machine code is the architecture-specific opcodes which have the simple task of adding two unsigned bytes together and making the result available to the high-level language.
For example, the following assembly language program is given f... | #FreeBASIC | FreeBASIC | '' This is an example for the x86 architecture.
Function test (Byval a As Long, Byval b As Long) As Long
Asm
mov eax, [a]
Add eax, [b]
mov [Function], eax
End Asm
End Function
Print test(12, 7)
Sleep |
http://rosettacode.org/wiki/Mandelbrot_set | Mandelbrot set | Mandelbrot set
You are encouraged to solve this task according to the task description, using any language you may know.
Task
Generate and draw the Mandelbrot set.
Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .
| #Prolog | Prolog | :- use_module(library(pce)).
mandelbrot :-
new(D, window('Mandelbrot Set')),
send(D, size, size(700, 650)),
new(Img, image(@nil, width := 700, height := 650, kind := pixmap)),
forall(between(0,699, I),
( forall(between(0,649, J),
( get_RGB(I, J, R, G, B),
... |
http://rosettacode.org/wiki/Matrix_multiplication | Matrix multiplication | Task
Multiply two matrices together.
They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.
| #Standard_ML | Standard ML | structure IMatrix = struct
fun dot(x,y) = Vector.foldli (fn (i,xi,agg) => agg+xi*Vector.sub(y,i)) 0 x
fun x*y =
let
open Array2
in
tabulate ColMajor (nRows x, nCols y, fn (i,j) => dot(row(x,i),column(y,j)))
end
end;
(* for display *)
fun toList a =
let
open Array2
in
List.tabulate(nRows a, fn i... |
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #TI-83_BASIC.2C_TI-89_BASIC | TI-83 BASIC, TI-89 BASIC | [A]T->[B]
|
http://rosettacode.org/wiki/Matrix_transposition | Matrix transposition | Transpose an arbitrarily sized rectangular Matrix.
| #True_BASIC | True BASIC | OPTION BASE 0
DIM matriz(3, 4)
DATA 78, 19, 30, 12, 36
DATA 49, 10, 65, 42, 50
DATA 30, 93, 24, 78, 10
DATA 39, 68, 27, 64, 29
FOR f = 0 TO 3
FOR c = 0 TO 4
READ matriz(f, c)
NEXT c
NEXT f
DIM mtranspuesta(0 TO 4, 0 TO 3)
FOR fila = LBOUND(matriz,1) TO UBOUND(matriz,1)
FOR columna = LBOUND(mat... |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Python | Python | import requests
for addr in ['88:53:2E:67:07:BE', 'FC:FB:FB:01:FA:21',
'D4:F4:6F:C9:EF:8D', '23:45:67']:
vendor = requests.get('http://api.macvendors.com/' + addr).text
print(addr, vendor) |
http://rosettacode.org/wiki/MAC_Vendor_Lookup | MAC Vendor Lookup | Every connected device around the world comes with a unique Media Access Control address, or a MAC address.
A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.
Task
Interface with one (or numerous) APIs that exist on the i... | #Racket | Racket | #lang racket
(require net/url)
(define (lookup-MAC-address addr)
(port->string
(get-pure-port
(url "http" #f "api.macvendors.com" #f #t (list (path/param addr null)) null #f))))
(module+ test
(for ((i (in-list '("88:53:2E:67:07:BE"
"FC:FB:FB:01:FA:21"
"D4:F4:6F:C9:... |
http://rosettacode.org/wiki/Magic_8-ball | Magic 8-ball | Task
Create Magic 8-Ball.
See details at: Magic 8-Ball.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioinformatics/base count
Count occurren... | #AWK | AWK |
# syntax: GAWK -f MAGIC_8-BALL.AWK
BEGIN {
# Ten answers are affirmative, five are non-committal, and five are negative.
arr[++i] = "It is certain"
arr[++i] = "It is decidedly so"
arr[++i] = "Without a doubt"
arr[++i] = "Yes, definitely"
arr[++i] = "You may rely on it"
arr[++i] = "As I see it,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.