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/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...
#Go
Go
package main   import "fmt"   /* #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> #include <string.h>   typedef unsigned char byte; typedef byte (*mcfunc) (byte, byte);   void runMachineCode(void *buf, byte a, byte b) { mcfunc fp = (mcfunc)buf; printf("%d\n", fp(a, b)); } */ import "C"   func main()...
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 .
#Python
Python
# Python 3.0+ and 2.5+ try: from functools import reduce except: pass     def mandelbrot(a): return reduce(lambda z, _: z * z + a, range(50), 0)   def step(start, step, iterations): return (start + (i * step) for i in range(iterations))   rows = (("*" if abs(mandelbrot(complex(x, y))) < 2 else " " ...
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.
#Stata
Stata
. mat a=1,2,3\4,5,6 . mat b=1,1,0,0\1,0,0,1\0,0,1,1 . mat c=a*b . mat list c   c[2,4] c1 c2 c3 c4 r1 3 1 3 5 r2 9 4 6 11
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Ursala
Ursala
#cast %eLL   example =   ~&K7 < <1.,2.,3.,4.>, <5.,6.,7.,8.>, <9.,10.,11.,12.>>
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#VBA
VBA
Function transpose(m As Variant) As Variant transpose = WorksheetFunction.transpose(m) End Function
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...
#Raku
Raku
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 rep...
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...
#Red
Red
print read rejoin [http://api.macvendors.com/ ask "MAC address: "]  
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...
#BASIC
BASIC
dim answer$(20) answer$[0] = "It is certain." answer$[1] = "It is decidedly so." answer$[2] = "Without a doubt." answer$[3] = "Yes - definitely." answer$[4] = "You may rely on it." answer$[5] = "As I see it, yes." answer$[6] = "Most likely." answer$[7] = "Outlook good." answer$[8] = "Yes." answer$[9] = "Signs point to ...
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...
#C
C
#include <stdio.h> #include <stdlib.h> #include <time.h>   int main() { char *question = NULL; size_t len = 0; ssize_t read; const char* answers[20] = { "It is certain", "It is decidedly so", "Without a doubt", "Yes, definitely", "You may rely on it", "As I see it, yes", "Most li...
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...
#Julia
Julia
using Cxx   cxx""" #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 ...
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...
#Kotlin
Kotlin
// mcode.def ---   static inline unsigned char runMachineCode(void *code, unsigned char a, unsigned char b) { return ((unsigned char (*) (unsigned char, unsigned char))code)(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 .
#R
R
iterate.until.escape <- function(z, c, trans, cond, max=50, response=dwell) { #we iterate all active points in the same array operation, #and keeping track of which points are still iterating. active <- seq_along(z) dwell <- z dwell[] <- 0 for (i in 1:max) { z[active] <- trans(z[active], c[active]); ...
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.
#Swift
Swift
@inlinable public func matrixMult<T: Numeric>(_ m1: [[T]], _ m2: [[T]]) -> [[T]] { let n = m1[0].count let m = m1.count let p = m2[0].count   guard m != 0 else { return [] }   precondition(n == m2.count)   var ret = Array(repeating: Array(repeating: T.zero, count: p), count: m)   for i in 0..<m { ...
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#VBScript
VBScript
  'create and display the initial matrix WScript.StdOut.WriteLine "Initial Matrix:" x = 4 : y = 6 : n = 1 Dim matrix() ReDim matrix(x,y) For i = 0 To y For j = 0 To x matrix(j,i) = n If j < x Then WScript.StdOut.Write n & vbTab Else WScript.StdOut.Write n End If n = n + 1 Next WScript.StdOut.WriteLin...
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...
#REXX
REXX
/*REXX pgm shows a network device's manufacturer based on the Media Access Control addr.*/ win_command = 'getmac' /*name of the Microsoft Windows command*/ win_command_options = '/v /fo list' /*options of " " " */ ?3= 'Network Adapter:' ...
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...
#C.2B.2B
C++
#include <array> #include <cstdlib> #include <ctime> #include <iostream> #include <string>   int main() { constexpr std::array<const char*, 20> answers = { "It is certain.", "It is decidedly so.", "Without a doubt.", "Yes - definitely.", "You may rely on it.", "As I s...
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...
#M2000_Interpreter
M2000 Interpreter
  Module Checkit { Buffer DataMem as Long*10 Return DataMem, 1:=500 ' second Long Print Eval(DataMem, 1)+5100+5=5605 \\ Now we do math executing machine code Buffer Code ExecMem as byte*1024 Address=0 EmbLong(0xb8, 5100) ' mov eax,5100 EmbByteByte(0x83, 0xC0, 5) ' add ...
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...
#Nim
Nim
import posix   let MAP_ANONYMOUS {.importc: "MAP_ANONYMOUS", header: "<sys/mman.h>".}: cint   proc test(a, b: cint): cint = # mov EAX, [ESP+4] # add EAX, [ESP+8] # ret var code = [0x8B'u8, 0x44, 0x24, 0x4, 0x3, 0x44, 0x24, 0x8, 0xC3]   # create an executable buffer var buf = mmap(nil, sizeof(code), PROT_REA...
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 .
#Racket
Racket
  #lang racket   (require racket/draw)   (define (iterations a z i) (define z′ (+ (* z z) a)) (if (or (= i 255) (> (magnitude z′) 2)) i (iterations a z′ (add1 i))))   (define (iter->color i) (if (= i 255) (make-object color% "black") (make-object color% (* 5 (modulo i 15)) (* 32 (modulo 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.
#Tailspin
Tailspin
  operator (A matmul B) $A -> \[i]( $B(1) -> \[j](@: 0; 1..$B::length -> @: $@ + $A($i;$) * $B($;$j); $@ !\) ! \) ! end matmul   templates printMatrix&{w:} templates formatN @: []; $ -> # '$@ -> $::length~..$w -> ' ';$@(last..1:-1)...;' ! when <1..> do ..|@: $ mod 10; $ ~/ 10 -> # ...
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Visual_Basic
Visual Basic
Option Explicit '---------------------------------------------------------------------- Function TransposeMatrix(InitMatrix() As Long, TransposedMatrix() As Long) Dim l1 As Long, l2 As Long, u1 As Long, u2 As Long, r As Long, c As Long l1 = LBound(InitMatrix, 1) l2 = LBound(InitMatrix, 2) u1 = UBound(InitMatrix, ...
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...
#Ring
Ring
  # Project: MAC Vendor Lookup   load "stdlib.ring" macs = ["FC-A1-3E","FC:FB:FB:01:FA:21","88:53:2E:67:07:BE","D4:F4:6F:C9:EF:8D"] for mac = 1 to len(macs) lookupvendor(macs[mac]) next   func lookupvendor(mac) url = download("api.macvendors.com/" + mac) see url + nl  
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...
#Ruby
Ruby
require 'net/http'   arr = ['88:53:2E:67:07:BE', 'FC:FB:FB:01:FA:21', 'D4:F4:6F:C9:EF:8D', '23:45:67']   arr.each do |addr| vendor = Net::HTTP.get('api.macvendors.com', "/#{addr}/") rescue nil puts "#{addr} #{vendor}" 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...
#Rust
Rust
extern crate reqwest;   use std::{thread, time};   fn get_vendor(mac: &str) -> Option<String> { let mut url = String::from("http://api.macvendors.com/"); url.push_str(mac); let url_ref = &url; match reqwest::get(url_ref) { Ok(mut res) => match res.text() { Ok(text) => { ...
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...
#C.23
C#
  using System;   namespace newProg {   class Program { static void Main(string[] args) { string[] answers = { "It is certain.", "It is decidedly so.", "Without a doubt.", "Yes – definitely.", ...
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...
#PARI.2FGP
PARI/GP
#include <stdio.h> #include <sys/mman.h> #include <string.h> #include <pari/pari.h>   int test(int a, int b) { 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),PROT_READ|PROT_WRITE|PROT_EXEC, MAP_P...
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 .
#Raku
Raku
constant @color_map = map ~*.comb(/../).map({:16($_)}), < 000000 0000fc 4000fc 7c00fc bc00fc fc00fc fc00bc fc007c fc0040 fc0000 fc4000 fc7c00 fcbc00 fcfc00 bcfc00 7cfc00 40fc00 00fc00 00fc40 00fc7c 00fcbc 00fcfc 00bcfc 007cfc 0040fc 7c7cfc 9c7cfc bc7cfc dc7cfc fc7cfc fc7cdc fc7cbc fc7c9c fc7c7c fc9c7c fcbc7c fcdc7c fc...
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.
#Tcl
Tcl
package require Tcl 8.5 namespace path ::tcl::mathop proc matrix_multiply {a b} { lassign [size $a] a_rows a_cols lassign [size $b] b_rows b_cols if {$a_cols != $b_rows} { error "incompatible sizes: a($a_rows, $a_cols), b($b_rows, $b_cols)" } set temp [lrepeat $a_rows [lrepeat $b_cols 0]] ...
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Wortel
Wortel
@zipm [[1 2 3] [4 5 6] [7 8 9]]
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Wren
Wren
import "/matrix" for Matrix import "/fmt" for Fmt   var m = Matrix.new([ [ 1, 2, 3], [ 4, 5, 6], [ 7, 8, 9], [10, 11, 12] ])   System.print("Original:\n") Fmt.mprint(m, 2, 0) System.print("\nTransposed:\n") Fmt.mprint(m.transpose, 2, 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...
#Scala
Scala
object LookUp extends App { val macs = Seq("FC-A1-3E", "FC:FB:FB:01:FA:21", "88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D")   def lookupVendor(mac: String) = scala.io.Source.fromURL("""http://api.macvendors.com/""" + mac, "UTF-8").mkString   macs.foreach(mac => println(lookupVendor(mac))) }
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...
#Tcl
Tcl
package require http   # finally is a bit like go's defer proc finally args { tailcall trace add variable :#finally#: unset [list apply [list args $args]] }   # basic wrapper for http::geturl proc geturl {url} { set tok [::http::geturl $url] finally ::http::cleanup $tok  ::http::data $tok } proc maclo...
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...
#CFEngine
CFEngine
  #!/var/cfengine/bin/cf-agent --no-lock bundle agent __main__ { methods: "rosettacode_org:magic_8_ball"; } body file control { namespace => "rosettacode_org"; } bundle agent magic_8_ball { vars: "_responses" slist => { "It is certain", "It is decidedly so", "Without a doubt",...
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...
#Clojure
Clojure
  (def responses ["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" "Do...
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...
#Pascal
Pascal
Program Example66; {Inspired... program to demonstrate the MMap function. Freepascal docs } Uses BaseUnix,Unix;   const code : array[0..9] of byte = ($8B, $44, $24, $4, $3, $44, $24, $8, $C3, $00); a :longInt= 12; b :longInt= 7; type tDummyFunc = function(a,b:LongInt):LongInt;cdecl; Var Len,k : cint;...
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 .
#REXX
REXX
/*REXX program generates and displays a Mandelbrot set as an ASCII art character image.*/ @ = '>=<;:9876543210/.-,+*)(''&%$#"!' /*the characters used in the display. */ Xsize = 59; minRE = -2; maxRE = +1; stepX = (maxRE-minRE) / Xsize Ysize = 21; minIM = -1; maxIM = +1; stepY = (maxIM-minIM) / ...
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.
#TI-83_BASIC
TI-83 BASIC
Disp [A]*[B]
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#XPL0
XPL0
proc Transpose(M, R, C, N); \Transpose matrix M to N int M, R, C, N; \rows and columns int I, J; [for I:= 0 to R-1 do for J:= 0 to C-1 do N(J,I):= M(I,J); ];   proc ShowMat(M, R, C); \Display matrix M int M, R, C; \rows and columns int I, J; [for I:= 0 to R-...
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...
#UNIX_Shell
UNIX Shell
  macList=("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");for burger in ${macList[@]};do curl http://api.macvendors.com/$burger && sleep 5 && echo;done  
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...
#VBScript
VBScript
  a=array("00-20-6b-ba-d0-cb","00-40-ae-04-87-86") set WebRequest = CreateObject("WinHttp.WinHttpRequest.5.1")   for each MAC in a if b<>0 then wscript.echo "Spacing next request...": wscript.sleep 2000 WebRequest.Open "GET", "http://api.macvendors.com/"& mac,1 WebRequest.Send() WebRequest.WaitForResponse ...
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...
#CMake
CMake
CMAKE_MINIMUM_REQUIRED(VERSION 3.6)   PROJECT(EightBall)   SET(CMAKE_DISABLE_SOURCE_CHANGES ON) SET(CMAKE_DISABLE_IN_SOURCE_BUILD ON)   LIST(APPEND RESPONSES "It is certain." "It is decidedly so." "Without a doubt.") LIST(APPEND RESPONSES "Yes - definitely." "You may rely on it.") LIST(APPEND RESPONSES "As I see it yes...
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...
#Phix
Phix
atom mem = allocate(9) poke(mem,{#8B,#44,#24,#04,#03,#44,#24,#08,#C3}) constant mfunc = define_c_func({},mem,{C_INT,C_INT},C_INT) ?c_func(mfunc,{12,7}) free(mem)
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...
#PicoLisp
PicoLisp
(setq P (struct (native "@" "malloc" 'N 39) 'N # Align 144 # nop 144 # nop   # Prepare stack 106 12 # pushq $12 184 7 0 0 0 # mov $7, %eax 72 193 224 32 # shl $32, %rax 80 # pushq %rax   ...
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 .
#Ring
Ring
  load "guilib.ring"   new qapp { win1 = new qwidget() { setwindowtitle("Mandelbrot set") setgeometry(100,100,500,500) label1 = new qlabel(win1) { setgeometry(10,10,400,400) settext("") } ...
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.
#TI-89_BASIC
TI-89 BASIC
[1,2; 3,4; 5,6; 7,8] → m1 [1,2,3; 4,5,6] → m2 m1 * m2
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Yabasic
Yabasic
dim matriz(4,5) dim mtranspuesta(5,4)   for fila = 1 to arraysize(matriz(), 1) for columna = 1 to arraysize(matriz(), 2) read matriz(fila, columna) print matriz(fila, columna); mtranspuesta(columna, fila) = matriz(fila, columna) next columna print next fila print   for fila = 1 to arraysize(mtranspuesta(...
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#zkl
zkl
var [const] GSL=Import("zklGSL"); // libGSL (GNU Scientific Library) GSL.Matrix(2,3).set(1,2,3, 4,5,6).transpose().format(5).println(); // in place println("---"); GSL.Matrix(2,2).set(1,2, 3,4).transpose().format(5).println(); // in place println("---"); GSL.Matrix(3,1).set(1,2,3).transpose().format(5).println(); //...
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...
#Wren
Wren
/* mac_vendor_lookup.wren */ class MAC { foreign static lookup(address) }   System.print(MAC.lookup("FC:FB:FB:01:FA:21")) for (i in 1..1e8) {} // slow down request System.print(MAC.lookup("23:45:67"))
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...
#zkl
zkl
var [const] CURL=Import("zklCurl"); // libcurl const MAC_VENDORS="http://api.macvendors.com/";   fcn lookUp(macAddress){ httpAddr:=MAC_VENDORS + macAddress; vender:=CURL().get(httpAddr); //-->(Data,bytes of header,bytes of trailer) vender=vender[0].del(0,vender[1]); // remove HTTP header vender.text; //...
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...
#Commodore_BASIC
Commodore BASIC
  10 dim f$(19):for i=0 to 19:read f$(i):next 20 print chr$(147);chr$(14) 30 print "Press any key to reveal your fortune." 40 print:print "Press Q to quit.":print 50 fo=int(rnd(1)*20):get k$:if k$="" then 50 60 if k$="q" then print "Good luck!":end 70 print "Your fortune reads:" 80 print spc(5);f$(fo):print 90 print "A...
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...
#D
D
import std.random, std.stdio, std.string;   const string[] responses = ["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 t...
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...
#PL.2FM
PL/M
100H:   /* 8080 MACHINE CODE TO ADD TWO BYTES: 79 MOV A,C  ; LOAD FIRST ARG INTO ACCUMULATOR 83 ADD E  ; ADD SECOND ARG TO ACCUMULATOR C9 RET  ; RETURN */   DECLARE ADD$8080 DATA (79H, 83H, 0C9H);   /* THE 8080 PL/M CALLING CONVENTION IS THAT THE NEXT-TO-LAST ARG IS PUT IN (...
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...
#PureBasic
PureBasic
CompilerIf #PB_Compiler_Processor <> #PB_Processor_x86 CompilerError "Code requires a 32-bit processor." CompilerEndIf     ; Machine code using the Windows API   Procedure MachineCodeVirtualAlloc(a,b) *vm = VirtualAlloc_(#Null,?ecode-?scode,#MEM_COMMIT,#PAGE_EXECUTE_READWRITE) If(*vm) CopyMemory(?scode, *...
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 .
#Ruby
Ruby
require 'complex'   def mandelbrot(a) Array.new(50).inject(0) { |z,c| z*z + a } end   (1.0).step(-1,-0.05) do |y| (-2.0).step(0.5,0.0315) do |x| print mandelbrot(Complex(x,y)).abs < 2 ? '*' : ' ' end puts end
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.
#Transd
Transd
#lang transd     MainModule: { _start: (λ (with n 5 A (for i in Range(n) project (for k in Range(n) project k)) B (for i in Range(n) project (for k in Range(n) project (- n k))) C (for i in Range(n) project (for k in Range(n) project 0))   (for i in Range( n ) do ...
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#zonnon
zonnon
  module MatrixOps; type Matrix = array {math} *,* of integer;     procedure WriteMatrix(x: array {math} *,* of integer); var i,j: integer; begin for i := 0 to len(x,0) - 1 do for j := 0 to len(x,1) - 1 do write(x[i,j]); end; writeln; end end WriteMatrix;   procedure Transposition; var m,x:...
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...
#Zoea
Zoea
  program: mac_vendor_lookup   data: 'http://api.macvendors.com/'   input: 'D4:F4:6F:C9:EF:8D' derive: 'http://api.macvendors.com/D4:F4:6F:C9:EF:8D' output: 'Apple, Inc.'  
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...
#Delphi
Delphi
  program Magic_8_ball;   {$APPTYPE CONSOLE}   uses System.SysUtils, windows;   // https://stackoverflow.com/questions/29794559/delphi-console-xe7-clearscreen procedure ClearScreen; var stdout: THandle; csbi: TConsoleScreenBufferInfo; ConsoleSize: DWORD; NumWritten: DWORD; Origin: TCoord; begin stdout :...
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...
#Python
Python
import ctypes import os from ctypes import c_ubyte, c_int   code = bytes([0x8b, 0x44, 0x24, 0x04, 0x03, 0x44, 0x24, 0x08, 0xc3])   code_size = len(code) # copy code into an executable buffer if (os.name == 'posix'): import mmap executable_map = mmap.mmap(-1, code_size, mmap.MAP_PRIVATE | mmap.MAP_ANON, mmap.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 .
#Rust
Rust
extern crate image; extern crate num_complex;   use std::fs::File; use num_complex::Complex;   fn main() { let max_iterations = 256u16; let img_side = 800u32; let cxmin = -2f32; let cxmax = 1f32; let cymin = -1.5f32; let cymax = 1.5f32; let scalex = (cxmax - cxmin) / img_side as f32; 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.
#UNIX_Shell
UNIX Shell
  #!/bin/bash   DELAY=0 # increase this if printing of matrices should be slower   echo "This script takes two matrices, henceforth called A and B, and returns their product, AB.   For the time being, matrices can have integer components only.   "   read -p "Number of rows of matrix A: " arows read -p "Number of co...
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...
#Factor
Factor
USING: io kernel random sequences ; IN: rosetta-code.magic-8-ball   CONSTANT: phrases { "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" "...
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...
#FreeBASIC
FreeBASIC
dim as string answer(0 to 19) = { "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...
#Quackery
Quackery
/O> ( check that + and negate are operators (i.e. op-codes ) ... ' + operator? ' negate operator? and if [ say "true"] ... true Stack empty. /O> ( create a memory block large enough to hold them, ) ... ( filled with zeros ) ... 0 2 of ... Stack: [ 0 0 ] /O> ( poke the + operator into place ) ... ' + swap 0 poke ...
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...
#Racket
Racket
#lang racket/base   (require ffi/unsafe)   ; set up access to racket internals (define scheme-malloc-code (get-ffi-obj 'scheme_malloc_code #f (_fun (len : _intptr) -> _pointer))) (define scheme-free-code (get-ffi-obj 'scheme_free_code #f (_fun _pointer -> _void)))   (define opcodes '(139 68 36 4 3 68 36 8 195))   (...
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 .
#Sass.2FSCSS
Sass/SCSS
  $canvasWidth: 200; $canvasHeight: 200; $iterations: 20; $xCorner: -2; $yCorner: -1.5; $zoom: 3; $data: ()!global; @mixin plot ($x,$y,$count){ $index: ($y * $canvasWidth + $x) * 4; $r: $count * -12 + 255; $g: $count * -12 + 255; $b: $count * -12 + 255; $data: append($data, $x + px $y + px 0 rgb($r,$g,$b), co...
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.
#Ursala
Ursala
#import rat   a =   < <1/1, 1/1, 1/1, 1/1>, <2/1, 4/1, 8/1, 16/1>, <3/1, 9/1, 27/1, 81/1>, <4/1, 16/1, 64/1, 256/1>>   b =   < < 4/1, -3/1, 4/3, -1/4>, <-13/3, 19/4, -7/3, 11/24>, < 3/2, -2/1, 7/6, -1/4>, < -1/6, 1/4, -1/6, 1/24>>   mmult = *rK7lD *rlD sum:-0.+ product*p   #ca...
http://rosettacode.org/wiki/Ludic_numbers
Ludic numbers
Ludic numbers   are related to prime numbers as they are generated by a sieve quite like the Sieve of Eratosthenes is used to generate prime numbers. The first ludic number is   1. To generate succeeding ludic numbers create an array of increasing integers starting from   2. 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1...
#11l
11l
F ludic(nmax = 100000) V r = [1] V lst = Array(2..nmax) L !lst.empty r.append(lst[0]) [Int] newlst V step = lst[0] L(i) 0 .< lst.len I i % step != 0 newlst.append(lst[i]) lst = newlst R r   V ludics = ludic() print(‘First 25 ludic primes:’) print(ludics[0.<...
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...
#Forth
Forth
\ magic eight ball Rosetta Code INCLUDE RANDOM.FS DECIMAL : CASE: ( -- -7) CREATE  ; : ;CASE ( n -- ) DOES> SWAP CELLS + @ EXECUTE ;   : VECTORS 0 DO , LOOP ;   :NONAME ." It is certain" ; :NONAME ." It is decidedly so" ; :NONAME ." Without a doubt" ; :NONAME ." Yes, definitely" ; :NONAME ." You m...
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...
#Fortran
Fortran
PROGRAM EIGHT_BALL CHARACTER(LEN=100) :: RESPONSE CHARACTER(LEN=100) :: QUESTION CHARACTER(LEN=100), DIMENSION(20) :: RESPONSES REAL :: R   CALL RANDOM_SEED()   RESPONSES(1) = "It is certain" RESPONSES(2) = "It is decidedly so" RESPONSES(3) = "Without a doubt" RESPONSES(4) = "Yes, d...
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...
#Raku
Raku
c = ((int (*) (int, int))buf)(a, 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...
#Rust
Rust
extern crate libc;   #[cfg(all( target_os = "linux", any(target_pointer_width = "32", target_pointer_width = "64") ))] fn main() { use std::mem; use std::ptr;   let page_size: usize = 4096; let (bytes, size): (Vec<u8>, usize) = if cfg!(target_pointer_width = "32") { ( vec![0x...
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 .
#Scala
Scala
import org.rosettacode.ArithmeticComplex._ import java.awt.Color   object Mandelbrot { def generate(width:Int =600, height:Int =400)={ val bm=new RgbBitmap(width, height)   val maxIter=1000 val xMin = -2.0 val xMax = 1.0 val yMin = -1.0 val yMax = 1.0   val cx=(xMax-xMin)/...
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.
#VBA
VBA
Function matrix_multiplication(a As Variant, b As Variant) As Variant matrix_multiplication = WorksheetFunction.MMult(a, b) End Function
http://rosettacode.org/wiki/Ludic_numbers
Ludic numbers
Ludic numbers   are related to prime numbers as they are generated by a sieve quite like the Sieve of Eratosthenes is used to generate prime numbers. The first ludic number is   1. To generate succeeding ludic numbers create an array of increasing integers starting from   2. 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1...
#360_Assembly
360 Assembly
* Ludic numbers 23/04/2016 LUDICN CSECT USING LUDICN,R15 set base register LH R9,NMAX r9=nmax SRA R9,1 r9=nmax/2 LA R6,2 i=2 LOOPI1 CR R6,R9 do i=2 to nmax/2 BH ELOOPI1 ...
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...
#Go
Go
package main   import ( "bufio" "bytes" "fmt" "log" "math/rand" "os" "time" )   func main() { rand.Seed(time.Now().UnixNano()) answers := [...]string{ "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", "Sig...
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...
#Scala
Scala
!ExternalBytes class methods!   mapExecutableBytes:size %{ # include <sys/mman.h>   void *mem; OBJ retVal; int nBytes = __intVal(size);   mem = mmap(nil, nBytes, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0); if (mem != MAP_FAILED) { RETURN( __MKEXTERNALBYTES_N(mem, nBytes))...
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...
#Smalltalk
Smalltalk
!ExternalBytes class methods!   mapExecutableBytes:size %{ # include <sys/mman.h>   void *mem; OBJ retVal; int nBytes = __intVal(size);   mem = mmap(nil, nBytes, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0); if (mem != MAP_FAILED) { RETURN( __MKEXTERNALBYTES_N(mem, nBytes))...
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 .
#Scheme
Scheme
(define x-centre -0.5) (define y-centre 0.0) (define width 4.0) (define i-max 800) (define j-max 600) (define n 100) (define r-max 2.0) (define file "out.pgm") (define colour-max 255) (define pixel-size (/ width i-max)) (define x-offset (- x-centre (* 0.5 pixel-size (+ i-max 1)))) (define y-offset (+ y-centre (* 0.5 pi...
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.
#VBScript
VBScript
  Dim matrix1(2,2) matrix1(0,0) = 3 : matrix1(0,1) = 7 : matrix1(0,2) = 4 matrix1(1,0) = 5 : matrix1(1,1) = -2 : matrix1(1,2) = 9 matrix1(2,0) = 8 : matrix1(2,1) = -6 : matrix1(2,2) = -5 Dim matrix2(2,2) matrix2(0,0) = 9 : matrix2(0,1) = 2 : matrix2(0,2) = 1 matrix2(1,0) = -7 : matrix2(1,1) = 3 : matrix2(1,2) = -10 mat...
http://rosettacode.org/wiki/Ludic_numbers
Ludic numbers
Ludic numbers   are related to prime numbers as they are generated by a sieve quite like the Sieve of Eratosthenes is used to generate prime numbers. The first ludic number is   1. To generate succeeding ludic numbers create an array of increasing integers starting from   2. 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1...
#ABAP
ABAP
CLASS lcl_ludic DEFINITION CREATE PUBLIC.   PUBLIC SECTION. TYPES: t_ludics TYPE SORTED TABLE OF i WITH UNIQUE KEY table_line. TYPES: BEGIN OF t_triplet, i1 TYPE i, i2 TYPE i, i3 TYPE i, END OF t_triplet. TYPES: t_triplets TYPE STANDARD TABLE OF t_triplet ...
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...
#GW-BASIC
GW-BASIC
0 DATA "It is certain.", "It is decidedly so." 20 DATA "Without a doubt.", "Yes - definitely." 30 DATA "You may rely on it.", "As I see it, yes." 40 DATA "Most likely.", "Outlook good." 50 DATA "Yes.", "Signs point to yes." 60 DATA "Reply hazy, try again.", "Ask again later." 70 DATA "Better not tell you now.", "Cannot...
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...
#Swift
Swift
import Foundation   typealias TwoIntsOneInt = @convention(c) (Int, Int) -> Int   let code = [ 144, // Align 144, 106, 12, // Prepare stack 184, 7, 0, 0, 0, 72, 193, 224, 32, 80, 139, 68, 36, 4, 3, 68, 36, 8, // Rosetta task code 76, 137, 227, // Get result 137, 195, 72, 193, 227, 4, 128, 203, 2, ...
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...
#Tcl
Tcl
package require critcl   critcl::ccode { #include <sys/mman.h> }   # Define a command using C. The C is embedded in Tcl, and will be # built into a shared library at runtime. Note that Tcl does not # provide a native way of doing this sort of thing; this thunk is # mandatory. critcl::cproc runMachineCode {Tcl_Obj* ...
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 .
#Scratch
Scratch
$ include "seed7_05.s7i"; include "float.s7i"; include "complex.s7i"; include "draw.s7i"; include "keybd.s7i"; # Display the Mandelbrot set, that are points z[0] in the complex plane # for which the sequence z[n+1] := z[n] ** 2 + z[0] (n >= 0) is bounded. # Since this program is computing intensive it should 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.
#Visual_FoxPro
Visual FoxPro
  LOCAL ARRAY a[4,2], b[2,3], c[4,3] CLOSE DATABASES ALL *!* The arrays could be created directly but I prefer to do this: CREATE CURSOR mat1 (c1 I, c2 I) CREATE CURSOR mat2 (c1 I, c2 I, c3 I) *!* Since matrix multiplication of integer arrays *!* involves only multiplication and addition, *!* the result will contain ...
http://rosettacode.org/wiki/Ludic_numbers
Ludic numbers
Ludic numbers   are related to prime numbers as they are generated by a sieve quite like the Sieve of Eratosthenes is used to generate prime numbers. The first ludic number is   1. To generate succeeding ludic numbers create an array of increasing integers starting from   2. 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1...
#Action.21
Action!
DEFINE NOTLUDIC="0" DEFINE LUDIC="1" DEFINE UNKNOWN="2"   PROC LudicSieve(BYTE ARRAY a INT count) INT i,j,k   SetBlock(a,count,UNKNOWN) a(0)=NOTLUDIC a(1)=LUDIC   i=2 WHILE i<count DO IF a(i)=UNKNOWN THEN a(i)=LUDIC j=i k=0 WHILE j<count DO IF a(j)=UNKNOWN THEN ...
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...
#Haskell
Haskell
import System.Random (getStdRandom, randomR) import Control.Monad (forever)   answers :: [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" , "Signs point t...
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...
#Wren
Wren
/* machine_code.wren */   class C { // pass the machine code in string form to the host foreign static runMachineCode(s, a, b) }   var a = 7 var b = 12   // x64 opcodes for this task var m = [ 0x55, 0x48, 0x89, 0xe5, 0x89, 0x7d, 0xfc, 0x89, 0x75, 0xf8, 0x8b, 0x75, 0xfc, 0x03, 0x75, 0xf8, 0x89, 0x7...
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 .
#Seed7
Seed7
$ include "seed7_05.s7i"; include "float.s7i"; include "complex.s7i"; include "draw.s7i"; include "keybd.s7i"; # Display the Mandelbrot set, that are points z[0] in the complex plane # for which the sequence z[n+1] := z[n] ** 2 + z[0] (n >= 0) is bounded. # Since this program is computing intensive it should 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.
#Wren
Wren
import "/matrix" for Matrix import "/fmt" for Fmt   var a = Matrix.new([ [1, 2], [3, 4], [5, 6], [7, 8] ])   var b = Matrix.new([ [1, 2, 3], [4, 5, 6] ])   System.print("Matrix A:\n") Fmt.mprint(a, 2, 0) System.print("\nMatrix B:\n") Fmt.mprint(b, 2, 0) System.print("\nMatrix A x B:\n") Fmt.mpri...
http://rosettacode.org/wiki/Mad_Libs
Mad Libs
This page uses content from Wikipedia. The original article was at Mad Libs. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) Mad Libs is a phrasal template word game where one player prompts another...
#11l
11l
V template = ‘<name> went for a walk in the park. <he or she> found a <noun>. <name> decided to take it home.’   F madlibs(template) print("The story template is:\n"template) V fields = sorted(Array(Set(re:‘<[^>]+>’.find_strings(template)))) V values = input("\nInput a comma-separated list of words to replace ...
http://rosettacode.org/wiki/Ludic_numbers
Ludic numbers
Ludic numbers   are related to prime numbers as they are generated by a sieve quite like the Sieve of Eratosthenes is used to generate prime numbers. The first ludic number is   1. To generate succeeding ludic numbers create an array of increasing integers starting from   2. 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1...
#Ada
Ada
with Ada.Text_IO; with Ada.Containers.Vectors;   procedure Ludic_Numbers is   package Lucid_Lists is new Ada.Containers.Vectors (Positive, Natural); use Lucid_Lists;   List : Vector;   procedure Fill is use type Ada.Containers.Count_Type; Vec  : Vector; Lucid : Natural; Index ...
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...
#J
J
  NB. translated from awk   prompt=: [: 1!:1 [: 1: echo   ANSWERS=: [;._2'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...
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...
#Java
Java
  import java.util.Random; import java.util.Scanner;   public class MagicEightBall {   public static void main(String[] args) { new MagicEightBall().run(); }   private static String[] ANSWERS = new String[] {"It is certain.", "It is decidedly so.", "Without a doubt.", "Yes - definitely.", ...
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...
#X86-64_Assembly
X86-64 Assembly
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Linux Build: ;; $ uasm -elf64 mexec.asm ;; $ gcc -o mexec mexec.o -no-pie ;; With MUSL libc ;; $ musl-gcc -o mexec mexec.o -e main -nostartfiles -no-pie ;; ;; Windows Build: ;; $ uasm64 -win64 mexec.asm ;; $ link /machine:x64 ...
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 .
#SenseTalk
SenseTalk
put 0 into oReal # Real origin put 0 into oImag # Imaginary origin put 0.5 into mag # Magnification   put oReal - .8 / mag into leftReal put oImag + .5 / mag into topImag put 1 / 200 / mag into inc   put [ (0,255,255), # aqua (0,0,255), # blue (255,0,255), # fuchsia (128,128,128), # gray (0,128,0), # green (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.
#XPL0
XPL0
proc Mat4x1Mul(M, V); \Multiply matrix M times column vector V real M, \4x4 matrix [M] * [V] -> [V] V; \column vector real W(4); \working copy of column vector int R; \row [for R:= 0 to 4-1 do W(R):= M(R,0)*V(0) + M(R,1)*V(1) + M(R,2)*V(2) + M(R,3)*V(3); for R:= 0 to 4-1 do V(R):= W(R); ];   p...
http://rosettacode.org/wiki/Mad_Libs
Mad Libs
This page uses content from Wikipedia. The original article was at Mad Libs. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) Mad Libs is a phrasal template word game where one player prompts another...
#Ada
Ada
with Ada.Text_IO, Ada.Command_Line, String_Helper;   procedure Madlib is   use String_Helper;   Text: Vector := Get_Vector(Ada.Command_Line.Argument(1)); M, N: Natural;   begin -- search for templates and modify the text accordingly for I in Text.First_Index .. Text.Last_Index loop loop Se...
http://rosettacode.org/wiki/Ludic_numbers
Ludic numbers
Ludic numbers   are related to prime numbers as they are generated by a sieve quite like the Sieve of Eratosthenes is used to generate prime numbers. The first ludic number is   1. To generate succeeding ludic numbers create an array of increasing integers starting from   2. 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1...
#ALGOL_68
ALGOL 68
# find some Ludic numbers #   # sieve the Ludic numbers up to 30 000 # INT max number = 30 000; [ 1 : max number ]INT candidates; FOR n TO UPB candidates DO candidates[ n ] := n OD; FOR n FROM 2 TO UPB candidates OVER 2 DO IF candidates[ n ] /= 0 THEN # hav...