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/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Idris
Idris
Idris> transpose [[1,2],[3,4],[5,6]] [[1, 3, 5], [2, 4, 6]] : List (List Integer)
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#Raku
Raku
constant mapping = :OPEN(' '), :N< ╵ >, :E< ╶ >, :NE< └ >, :S< ╷ >, :NS< │ >, :ES< ┌ >, :NES< ├ >, :W< ╴ >, :NW< ┘ >, :EW< ─ >, :NEW< ┴ >, :SW< ┐ >, :NSW< ┤ >, :ESW< ┬ >, :NESW< ┼ >, :TODO< x >, :TRIED...
http://rosettacode.org/wiki/Map_range
Map range
Given two ranges:   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   and   [ b 1 , b 2 ] {\displaystyle [b_{1},b_{2}]} ;   then a value   s {\displaystyle s}   in range   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   is linearly mapped to a value   t {\di...
#Stata
Stata
program define maprange version 15.1 syntax varname(numeric) [if] [in], /// from(numlist min=2 max=2) to(numlist min=2 max=2) /// GENerate(name) [REPLACE] tempname a b c d h sca `a'=`:word 1 of `from'' sca `b'=`:word 2 of `from'' sca `c'=`:word 1 of `to'' sca `d'=`:word 2 of `to'' sca `h'=(`d'-`c')/(`b'-`a'...
http://rosettacode.org/wiki/Map_range
Map range
Given two ranges:   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   and   [ b 1 , b 2 ] {\displaystyle [b_{1},b_{2}]} ;   then a value   s {\displaystyle s}   in range   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   is linearly mapped to a value   t {\di...
#Swift
Swift
import Foundation   func mapRanges(_ r1: ClosedRange<Double>, _ r2: ClosedRange<Double>, to: Double) -> Double { let num = (to - r1.lowerBound) * (r2.upperBound - r2.lowerBound) let denom = r1.upperBound - r1.lowerBound   return r2.lowerBound + num / denom }   for i in 0...10 { print(String(format: "%2d maps to...
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#PowerShell
PowerShell
$string = "The quick brown fox jumped over the lazy dog's back" $data = [Text.Encoding]::UTF8.GetBytes($string) $hash = [Security.Cryptography.MD5]::Create().ComputeHash($data) ([BitConverter]::ToString($hash) -replace '-').ToLower()
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 .
#Furor
Furor
  ###sysinclude X.uh $ff0000 sto szin 300 sto maxiter maxypixel sto YRES maxxpixel sto XRES myscreen "Mandelbrot" @YRES @XRES graphic @YRES 2 / (#d) sto y2 @YRES 2 / (#d) sto x2 #g 0. @XRES (#d) 1. i: {#d #g 0. @YRES (#d) 1. {#d #d {#d}§i 400. - @x2 - @x2 / sto x {#d} @y2 - @y2 / sto y zero#d xa zero#d ya zero iter (...
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#Rust
Rust
fn main() { let n = 9; let mut square = vec![vec![0; n]; n]; for (i, row) in square.iter_mut().enumerate() { for (j, e) in row.iter_mut().enumerate() { *e = n * (((i + 1) + (j + 1) - 1 + (n >> 1)) % n) + (((i + 1) + (2 * (j + 1)) - 2) % n) + 1; print!("{:3} ", e); } ...
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#Scala
Scala
def magicSquare( n:Int ) : Option[Array[Array[Int]]] = { require(n % 2 != 0, "n must be an odd number")   val a = Array.ofDim[Int](n,n)   // Make the horizontal by starting in the middle of the row and then taking a step back every n steps val ii = Iterator.continually(0 to n-1).flatten.drop(n/2).slid...
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.
#Java
Java
public static double[][] mult(double a[][], double b[][]){//a[m][n], b[n][p] if(a.length == 0) return new double[0][0]; if(a[0].length != b.length) return null; //invalid dims   int n = a[0].length; int m = a.length; int p = b[0].length;   double ans[][] = new double[m][p];   for(int i = 0;i < m;i+...
http://rosettacode.org/wiki/Man_or_boy_test
Man or boy test
Man or boy test You are encouraged to solve this task according to the task description, using any language you may know. Background: The man or boy test was proposed by computer scientist Donald Knuth as a means of evaluating implementations of the ALGOL 60 programming language. The aim of the test was to distinguis...
#Swift
Swift
func A(_ k: Int, _ x1: @escaping () -> Int, _ x2: @escaping () -> Int, _ x3: @escaping () -> Int, _ x4: @escaping () -> Int, _ x5: @escaping () -> Int) -> Int { var k1 = k   func B() -> I...
http://rosettacode.org/wiki/Man_or_boy_test
Man or boy test
Man or boy test You are encouraged to solve this task according to the task description, using any language you may know. Background: The man or boy test was proposed by computer scientist Donald Knuth as a means of evaluating implementations of the ALGOL 60 programming language. The aim of the test was to distinguis...
#Tcl
Tcl
proc A {k x1 x2 x3 x4 x5} { expr {$k<=0 ? [eval $x4]+[eval $x5] : [B \#[info level]]} } proc B {level} { upvar $level k k x1 x1 x2 x2 x3 x3 x4 x4 incr k -1 A $k [info level 0] $x1 $x2 $x3 $x4 } proc C {val} {return $val} interp recursionlimit {} 1157 A 10 {C 1} {C -1} {C -1} {C 1} {C 0}
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#J
J
]matrix=: (^/ }:) >:i.5 NB. make and show example matrix 1 1 1 1 2 4 8 16 3 9 27 81 4 16 64 256 5 25 125 625 |: matrix 1 2 3 4 5 1 4 9 16 25 1 8 27 64 125 1 16 81 256 625
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#Rascal
Rascal
import IO; import util::Math; import List;   public void make_maze(int w, int h){ vis = [[0 | _ <- [1..w]] | _ <- [1..h]]; ver = [["| "| _ <- [1..w]] + ["|"] | _ <- [1..h]] + [[]]; hor = [["+--"| _ <- [1..w]] + ["+"] | _ <- [1..h + 1]];   void walk(int x, int y){ vis[y][x] = 1;   d = [<x - 1, y>, <x, y + 1>, <...
http://rosettacode.org/wiki/Map_range
Map range
Given two ranges:   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   and   [ b 1 , b 2 ] {\displaystyle [b_{1},b_{2}]} ;   then a value   s {\displaystyle s}   in range   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   is linearly mapped to a value   t {\di...
#Tcl
Tcl
package require Tcl 8.5 proc rangemap {rangeA rangeB value} { lassign $rangeA a1 a2 lassign $rangeB b1 b2 expr {$b1 + ($value - $a1)*double($b2 - $b1)/($a2 - $a1)} }
http://rosettacode.org/wiki/Map_range
Map range
Given two ranges:   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   and   [ b 1 , b 2 ] {\displaystyle [b_{1},b_{2}]} ;   then a value   s {\displaystyle s}   in range   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   is linearly mapped to a value   t {\di...
#Ursala
Ursala
#import flo   f((("a1","a2"),("b1","b2")),"s") = plus("b1",div(minus("s","a1"),minus("a2","a1")))   #cast %eL   test = f* ((0.,10.),(-1.,0.))-* ari11/0. 10.
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#PureBasic
PureBasic
UseMD5Fingerprint() ; register the MD5 fingerprint plugin   test$ = "The quick brown fox jumped over the lazy dog's back"   ; Call StringFingerprint() function and display MD5 result in Debug window Debug StringFingerprint(test$, #PB_Cipher_MD5)  
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 .
#Futhark
Futhark
  default(f32)   type complex = (f32, f32)   fun dot(c: complex): f32 = let (r, i) = c in r * r + i * i   fun multComplex(x: complex, y: complex): complex = let (a, b) = x let (c, d) = y in (a*c - b * d, a*d + b * c)   fun addComplex(x: complex, y: complex): complex = let (a, b) = x let (c, d) = y ...
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#Seed7
Seed7
$ include "seed7_05.s7i";   const func integer: succ (in integer: num, in integer: max) is return succ(num mod max);   const func integer: pred (in integer: num, in integer: max) is return succ((num - 2) mod max);   const proc: main is func local var integer: size is 3; var array array integer: magic is 0...
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#Sidef
Sidef
func magic_square(n {.is_pos && .is_odd}) { var i = 0 var j = int(n/2)   var magic_square = [] for l in (1 .. n**2) { magic_square[i][j] = l   if (magic_square[i.dec % n][j.inc % n]) { i = (i.inc % n) } else { i = (i.dec % n) j = (j.inc...
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.
#JavaScript
JavaScript
// returns a new matrix Matrix.prototype.mult = function(other) { if (this.width != other.height) { throw "error: incompatible sizes"; }   var result = []; for (var i = 0; i < this.height; i++) { result[i] = []; for (var j = 0; j < other.width; j++) { var sum = 0; ...
http://rosettacode.org/wiki/Man_or_boy_test
Man or boy test
Man or boy test You are encouraged to solve this task according to the task description, using any language you may know. Background: The man or boy test was proposed by computer scientist Donald Knuth as a means of evaluating implementations of the ALGOL 60 programming language. The aim of the test was to distinguis...
#TSQL
TSQL
  CREATE PROCEDURE dbo.LAMBDA_WRAP_INTEGER   @v INT   AS DECLARE @name NVARCHAR(MAX) = 'LAMBDA_' + UPPER(REPLACE(NEWID(), '-', '_')) DECLARE @SQL NVARCHAR(MAX) = ' CREATE PROCEDURE dbo.' + @name + ' AS   RETURN ' + CAST(@v AS NVARCHAR(MAX))   EXEC(@SQL) RETURN OBJECT_ID(@name) GO   CREATE PROCEDURE dbo....
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Java
Java
import java.util.Arrays; public class Transpose{ public static void main(String[] args){ double[][] m = {{1, 1, 1, 1}, {2, 4, 8, 16}, {3, 9, 27, 81}, {4, 16, 64, 256}, {5, 25...
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#Red
Red
Red ["Maze generation"]   size: as-pair to-integer ask "Maze width: " to-integer ask "Maze height: " random/seed now/time offsetof: function [pos] [pos/y * size/x + pos/x + 1] visited?: function [pos] [find visited pos]   newneighbour: function [pos][ nnbs: collect [ if all [pos/x > 0 not visited? p: pos - 1x0] [ke...
http://rosettacode.org/wiki/Map_range
Map range
Given two ranges:   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   and   [ b 1 , b 2 ] {\displaystyle [b_{1},b_{2}]} ;   then a value   s {\displaystyle s}   in range   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   is linearly mapped to a value   t {\di...
#Vala
Vala
double map_range(double s, int a1, int a2, int b1, int b2) { return b1+(s-a1)*(b2-b1)/(a2-a1); }   void main() { for (int s = 0; s < 11; s++){ print("%2d maps to %5.2f\n", s, map_range(s, 0, 10, -1, 0)); } }
http://rosettacode.org/wiki/Map_range
Map range
Given two ranges:   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   and   [ b 1 , b 2 ] {\displaystyle [b_{1},b_{2}]} ;   then a value   s {\displaystyle s}   in range   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   is linearly mapped to a value   t {\di...
#WDTE
WDTE
let mapRange r1 r2 s => + (at r2 0) (/ (* (- s (at r1 0) ) (- (at r2 1) (at r2 0) ) ) (- (at r1 1) ...
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#Python
Python
>>> import hashlib >>> # RFC 1321 test suite: >>> tests = ( (b"", 'd41d8cd98f00b204e9800998ecf8427e'), (b"a", '0cc175b9c0f1b6a831c399e269772661'), (b"abc", '900150983cd24fb0d6963f7d28e17f72'), (b"message digest", 'f96b697d7cb7938d525a2f31aaf161d0'), (b"abcdefghijklmnopqrstuvwxyz", 'c3fcd3d76192e4007dfb496c...
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 .
#FutureBasic
FutureBasic
  _xmin = -8601 _xmax = 2867 _ymin = -4915 _ymax = 4915 _maxiter = 32 _dx = ( _xmax - _xmin ) / 79 _dy = ( _ymax - _ymin ) / 24   void local fn MandelbrotSet printf @"\n" SInt32 cy = _ymin while ( cy <= _ymax ) SInt32 cx = _xmin while ( cx <= _xmax ) SInt32 x = 0 SInt32 y = ...
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#Stata
Stata
. mata magic(5) 1 2 3 4 5 +--------------------------+ 1 | 17 24 1 8 15 | 2 | 23 5 7 14 16 | 3 | 4 6 13 20 22 | 4 | 10 12 19 21 3 | 5 | 11 18 25 2 9 | +--------------------------+
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#Swift
Swift
extension String: Error {}   struct Point: CustomStringConvertible { var x: Int var y: Int   init(_ _x: Int, _ _y: Int) { self.x = _x self.y = _y }   var description: String { return "(\(x), \(y))\n" } }   extension Point: Equatable,Comparable { static func =...
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.
#jq
jq
def dot_product(a; b): a as $a | b as $b | reduce range(0;$a|length) as $i (0; . + ($a[$i] * $b[$i]) );   # transpose/0 expects its input to be a rectangular matrix (an array of equal-length arrays) def transpose: if (.[0] | length) == 0 then [] else [map(.[0])] + (map(.[1:]) | transpose) end ;   # A and B sh...
http://rosettacode.org/wiki/Man_or_boy_test
Man or boy test
Man or boy test You are encouraged to solve this task according to the task description, using any language you may know. Background: The man or boy test was proposed by computer scientist Donald Knuth as a means of evaluating implementations of the ALGOL 60 programming language. The aim of the test was to distinguis...
#TXR
TXR
(defun A (k x1 x2 x3 x4 x5) (labels ((B () (dec k) [A k B x1 x2 x3 x4])) (if (<= k 0) (+ [x4] [x5]) (B))))   (prinl (A 10 (ret 1) (ret -1) (ret -1) (ret 1) (ret 0)))
http://rosettacode.org/wiki/Man_or_boy_test
Man or boy test
Man or boy test You are encouraged to solve this task according to the task description, using any language you may know. Background: The man or boy test was proposed by computer scientist Donald Knuth as a means of evaluating implementations of the ALGOL 60 programming language. The aim of the test was to distinguis...
#Visual_Prolog
Visual Prolog
  implement main open core   clauses run():- console::init(), stdio::write(a(10, {() = 1}, {() = -1}, {() = -1}, {() = 1}, {() = 0})).   class predicates a : (integer K, function{integer} X1, function{integer} X2, function{integer} X3, function{integer} X4, function{integer} X5) -> integer R...
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#JavaScript
JavaScript
function Matrix(ary) { this.mtx = ary this.height = ary.length; this.width = ary[0].length; }   Matrix.prototype.toString = function() { var s = [] for (var i = 0; i < this.mtx.length; i++) s.push( this.mtx[i].join(",") ); return s.join("\n"); }   // returns a new matrix Matrix.prototyp...
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#REXX
REXX
/*REXX program generates and displays a rectangular solvable maze (of any size). */ parse arg rows cols seed . /*allow user to specify the maze size. */ if rows='' | rows==',' then rows= 19 /*No rows given? Then use the default.*/ if cols='' | cols==',' then cols= 19 ...
http://rosettacode.org/wiki/Map_range
Map range
Given two ranges:   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   and   [ b 1 , b 2 ] {\displaystyle [b_{1},b_{2}]} ;   then a value   s {\displaystyle s}   in range   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   is linearly mapped to a value   t {\di...
#Wren
Wren
import "/fmt" for Fmt   var mapRange = Fn.new { |a, b, s| b.from + (s - a.from) * (b.to - b.from) / (a.to - a.from) }   var a = 0..10 var b = -1..0 for (s in a) { var t = mapRange.call(a, b, s) var f = (t >= 0) ? " " : "" System.print("%(Fmt.d(2, s)) maps to %(f)%(t)") }
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#R
R
library(digest) hexdigest <- digest("The quick brown fox jumped over the lazy dog's back", algo="md5", serialize=FALSE)
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 .
#F.C5.8Drmul.C3.A6
Fōrmulæ
  const int MaxIterations = 1000; const vec2 Focus = vec2(-0.51, 0.54); const float Zoom = 1.0;   vec3 color(int iteration, float sqLengthZ) { // If the point is within the mandlebrot set // just color it black if(iteration == MaxIterations) return vec3(0.0);   // Else we give it a smoothed colo...
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#Tcl
Tcl
proc magicSquare {order} { if {!($order & 1) || $order < 0} { error "order must be odd and positive" } set s [lrepeat $order [lrepeat $order 0]] set x [expr {$order / 2}] set y 0 for {set i 1} {$i <= $order**2} {incr i} { lset s $y $x $i set x [expr {($x + 1) % $order}] set y [expr {($y - 1)...
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.
#Jsish
Jsish
/* Matrix multiplication, in Jsish */ require('Matrix');   if (Interp.conf('unitTest')) { var a = new Matrix([[1,2],[3,4]]); var b = new Matrix([[-3,-8,3],[-2,1,4]]); ; a; ; b; ; a.mult(b); }   /* =!EXPECTSTART!= a ==> { height:2, mtx:[ [ 1, 2 ], [ 3, 4 ] ], width:2 } b ==> { height:2, mtx:[ [ -3, -8, ...
http://rosettacode.org/wiki/Man_or_boy_test
Man or boy test
Man or boy test You are encouraged to solve this task according to the task description, using any language you may know. Background: The man or boy test was proposed by computer scientist Donald Knuth as a means of evaluating implementations of the ALGOL 60 programming language. The aim of the test was to distinguis...
#Vorpal
Vorpal
self.a = method(k, x1, x2, x3, x4, x5){ b = method(){ code.k = code.k - 1 return( self.a(code.k, code, code.x1, code.x2, code.x3, code.x4) ) } b.k = k b.x1 = x1 b.x2 = x2 b.x3 = x3 b.x4 = x4 b.x5 = x5   if(k <= 0){ return(self.apply(x4) + self.apply(x5)) } else{ return(self.apply(b...
http://rosettacode.org/wiki/Man_or_boy_test
Man or boy test
Man or boy test You are encouraged to solve this task according to the task description, using any language you may know. Background: The man or boy test was proposed by computer scientist Donald Knuth as a means of evaluating implementations of the ALGOL 60 programming language. The aim of the test was to distinguis...
#Wren
Wren
import "/fmt" for Fmt   var a a = Fn.new { |k, x1, x2, x3, x4, x5| var b b = Fn.new { k = k - 1 return a.call(k, b, x1, x2, x3, x4) } return (k <= 0) ? x4.call() + x5.call() : b.call() }   System.print(" k a") for (k in 0..20) { Fmt.print("$2d : $ d", k, a.call(k, Fn.new { 1 }, Fn...
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Joy
Joy
DEFINE transpose == [ [null] [true] [[null] some] ifte ] [ pop [] ] [ [[first] map] [[rest] map] cleave ] [ cons ] linrec .
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#Ruby
Ruby
class Maze DIRECTIONS = [ [1, 0], [-1, 0], [0, 1], [0, -1] ]   def initialize(width, height) @width = width @height = height @start_x = rand(width) @start_y = 0 @end_x = rand(width) @end_y = height - 1   # Which walls do exist? Default to "true". Both arrays are # one element ...
http://rosettacode.org/wiki/Map_range
Map range
Given two ranges:   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   and   [ b 1 , b 2 ] {\displaystyle [b_{1},b_{2}]} ;   then a value   s {\displaystyle s}   in range   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   is linearly mapped to a value   t {\di...
#XPL0
XPL0
include c:\cxpl\codes;   func real Map(A1, A2, B1, B2, S); real A1, A2, B1, B2, S; return B1 + (S-A1)*(B2-B1)/(A2-A1);   int I; [for I:= 0 to 10 do [if I<10 then ChOut(0, ^ ); IntOut(0, I); RlOut(0, Map(0., 10., -1., 0., float(I))); CrLf(0); ]; ]
http://rosettacode.org/wiki/Map_range
Map range
Given two ranges:   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   and   [ b 1 , b 2 ] {\displaystyle [b_{1},b_{2}]} ;   then a value   s {\displaystyle s}   in range   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   is linearly mapped to a value   t {\di...
#Yabasic
Yabasic
sub MapRange(s, a1, a2, b1, b2) return b1+(s-a1)*(b2-b1)/(a2-a1) end sub   for i = 0 to 10 step 2 print i, " : ", MapRange(i,0,10,-1,0) next
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#Racket
Racket
  #lang racket (require file/md5)   (md5 "") (md5 "a") (md5 "abc") (md5 "message digest") (md5 "abcdefghijklmnopqrstuvwxyz") (md5 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") (md5 "12345678901234567890123456789012345678901234567890123456789012345678901234567890")  
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 .
#GLSL
GLSL
  const int MaxIterations = 1000; const vec2 Focus = vec2(-0.51, 0.54); const float Zoom = 1.0;   vec3 color(int iteration, float sqLengthZ) { // If the point is within the mandlebrot set // just color it black if(iteration == MaxIterations) return vec3(0.0);   // Else we give it a smoothed colo...
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#TI-83_BASIC
TI-83 BASIC
9→N DelVar [A]:{N,N}→dim([A]) For(I,1,N) For(J,1,N) Remainder(I*2-J+N-1,N)*N+Remainder(I*2+J-2,N)+1→[A](I,J) End End [A]
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#uBasic.2F4tH
uBasic/4tH
' ------=< MAIN >=------   Proc _magicsq(5) Proc _magicsq(11) End   _magicsq Param (1) Local (4)   ' reset the array For b@ = 0 to 255 @(b@) = 0 Next   If ((a@ % 2) = 0) + (a@ < 3) + (a@ > 15) Then Print "error: size is not odd or size is smaller then 3 or bigger than 15" Return...
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.
#Julia
Julia
julia> [1 2 3 ; 4 5 6] * [1 2 ; 3 4 ; 5 6] # product of a 2x3 by a 3x2 2x2 Array{Int64,2}: 22 28 49 64   julia> [1 2 3] * [1,2,3] # product of a row vector by a column vector 1-element Array{Int64,1}: 14  
http://rosettacode.org/wiki/Man_or_boy_test
Man or boy test
Man or boy test You are encouraged to solve this task according to the task description, using any language you may know. Background: The man or boy test was proposed by computer scientist Donald Knuth as a means of evaluating implementations of the ALGOL 60 programming language. The aim of the test was to distinguis...
#zkl
zkl
fcn A(k, x1, x2, x3, x4, x5){ // -->1,0,-2,0,1,0,1,-1,-10,-30,-67,-138 B:=CB(k, x1, x2, x3, x4, x5); if(k <= 0) x4()+x5() else B.B(); }   foreach k in (12){ println("k=%2d A=%d".fmt(k, A(k, 1, -1, -1, 1, 0))) }   class CB{ var k, x1, x2, x3, x4, x5; fcn init{ k, x1, x2, x3, x4, x5 = vm.arglist; } fcn B...
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#jq
jq
def transpose: if (.[0] | length) == 0 then [] else [map(.[0])] + (map(.[1:]) | transpose) end ;
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#Rust
Rust
use rand::{thread_rng, Rng, rngs::ThreadRng};   const WIDTH: usize = 16; const HEIGHT: usize = 16;   #[derive(Clone, Copy)] struct Cell { col: usize, row: usize, }   impl Cell { fn from(col: usize, row: usize) -> Cell { Cell {col, row} } }   struct Maze { cells: [[bool; HEIGHT]; WIDTH], ...
http://rosettacode.org/wiki/Map_range
Map range
Given two ranges:   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   and   [ b 1 , b 2 ] {\displaystyle [b_{1},b_{2}]} ;   then a value   s {\displaystyle s}   in range   [ a 1 , a 2 ] {\displaystyle [a_{1},a_{2}]}   is linearly mapped to a value   t {\di...
#zkl
zkl
fcn mapRange([(a1,a2)], [(b1,b2)], s) // a1a2 is List(a1,a2) { b1 + ((s - a1) * (b2 - b1) / (a2 - a1)) }   r1:=T(0.0, 10.0); r2:=T(-1.0, 0.0); foreach s in ([0.0 .. 10]){ "%2d maps to %5.2f".fmt(s,mapRange(r1,r2, s)).println(); }
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#Raku
Raku
use Digest::MD5; say Digest::MD5.md5_hex: "The quick brown fox jumped over the lazy dog's back";
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 .
#gnuplot
gnuplot
set terminal png set output 'mandelbrot.png'
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#VBA
VBA
Sub magicsquare() 'Magic squares of odd order Const n = 9 Dim i As Integer, j As Integer, v As Integer Debug.Print "The square order is: " & n For i = 1 To n For j = 1 To n Cells(i, j) = ((i * 2 - j + n - 1) Mod n) * n + ((i * 2 + j - 2) Mod n) + 1 Next j Next i D...
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#VBScript
VBScript
  Sub magic_square(n) Dim ms() ReDim ms(n-1,n-1) inc = 0 count = 1 row = 0 col = Int(n/2) Do While count <= n*n ms(row,col) = count count = count + 1 If inc < n-1 Then inc = inc + 1 row = row - 1 col = col + 1 If row >= 0 Then If col > n-1 Then col = 0 End If Else row = n-1 ...
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.
#K
K
(1 2;3 4)_mul (5 6;7 8) (19 22 43 50)
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Jsish
Jsish
/* Matrix transposition, multiplication, identity, and exponentiation, in Jsish */ function Matrix(ary) { this.mtx = ary; this.height = ary.length; this.width = ary[0].length; }   Matrix.prototype.toString = function() { var s = []; for (var i = 0; i < this.mtx.length; i++) s.push(this.mtx[i].join("...
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#Scala
Scala
import scala.util.Random   object MazeTypes { case class Direction(val dx: Int, val dy: Int)   case class Loc(val x: Int, val y: Int) { def +(that: Direction): Loc = Loc(x + that.dx, y + that.dy) }   case class Door(val from: Loc, to: Loc)   val North = Direction(0,-1) val South = Direction(0,1) val W...
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#REBOL
REBOL
>> checksum/method "The quick brown fox jumped over the lazy dog" 'md5 == #{08A008A01D498C404B0C30852B39D3B8}
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 .
#Go
Go
package main   import "fmt" import "math/cmplx"   func mandelbrot(a complex128) (z complex128) { for i := 0; i < 50; i++ { z = z*z + a } return }   func main() { for y := 1.0; y >= -1.0; y -= 0.05 { for x := -2.0; x <= 0.5; x += 0.0315 { if cmplx.Abs(mandelbrot(complex(x, y))...
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#Visual_Basic
Visual Basic
Sub magicsquare() 'Magic squares of odd order Const n = 9 Dim i As Integer, j As Integer, v As Integer Debug.Print "The square order is: " & n For i = 1 To n For j = 1 To n v = ((i * 2 - j + n - 1) Mod n) * n + ((i * 2 + j - 2) Mod n) + 1 Debug.Print Right(Space(5) & ...
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.
#Klong
Klong
mul::{[a b];b::+y;{a::x;+/'{a*x}'b}'x} [[1 2] [3 4]] mul [[5 6] [7 8]] [[19 22] [43 50]]
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Julia
Julia
julia> [1 2 3 ; 4 5 6] # a 2x3 matrix 2x3 Array{Int64,2}: 1 2 3 4 5 6   julia> [1 2 3 ; 4 5 6]' # note the quote 3x2 LinearAlgebra.Adjoint{Int64,Array{Int64,2}}: 1 4 2 5 3 6
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#Sidef
Sidef
var(w:5, h:5) = ARGV.map{.to_i}... var avail = (w * h)   # cell is padded by sentinel col and row, so I don't check array bounds var cell = (1..h -> map {([true] * w) + [false]} + [[false] * w+1]) var ver = (1..h -> map {["| "] * w }) var hor = (0..h -> map {["+--"] * w })   func walk(x, y) { cell[y][x] = false;...
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#REXX
REXX
/*REXX program tests the MD5 procedure (below) as per a test suite the IETF RFC (1321).*/ msg.1 = /*─────MD5 test suite [from above doc].*/ msg.2 = 'a' msg.3 = 'abc' msg.4 = 'message digest' msg.5 = 'abcdefghijklmnopqrstuvwxyz' msg.6 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmno...
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 .
#Golfscript
Golfscript
20{40{0.1{.{;..*2$.*\- 20/3$-@@*10/3$-..*2$.*+1600<}*}32*' *'=\;\;@@(}60*;(n\}40*;]''+
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#Visual_Basic_.NET
Visual Basic .NET
Sub magicsquare() 'Magic squares of odd order Const n = 9 Dim i, j, v As Integer Console.WriteLine("The square order is: " & n) For i = 1 To n For j = 1 To n v = ((i * 2 - j + n - 1) Mod n) * n + ((i * 2 + j - 2) Mod n) + 1 Console.Write(" " & Right(Space(5) & v, 5)) ...
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.
#Kotlin
Kotlin
// version 1.1.3   typealias Vector = DoubleArray typealias Matrix = Array<Vector>   operator fun Matrix.times(other: Matrix): Matrix { val rows1 = this.size val cols1 = this[0].size val rows2 = other.size val cols2 = other[0].size require(cols1 == rows2) val result = Matrix(rows1) { Vector(cols...
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#K
K
{x^\:-1_ x}1+!:5 (1 1 1 1.0 2 4 8 16.0 3 9 27 81.0 4 16 64 256.0 5 25 125 625.0)   +{x^\:-1_ x}1+!:5 (1 2 3 4 5.0 1 4 9 16 25.0 1 8 27 64 125.0 1 16 81 256 625.0)
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#SuperCollider
SuperCollider
  // some useful functions ( ~grid = { 0 ! 60 } ! 60;   ~at = { |coord| var col = ~grid.at(coord[0]); if(col.notNil) { col.at(coord[1]) } }; ~put = { |coord, value| var col = ~grid.at(coord[0]); if(col.notNil) { col.put(coord[1], value) } };   ~coord = ~grid.shape.rand; ~next = { |p| var possible = [p] + [[0, 1], ...
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#Ring
Ring
  See MD5("my string!") + nl # output : a83a049fbe50cf7334caa86bf16a3520  
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 .
#Hare
Hare
use fmt; use math;   type complex = struct { re: f64, im: f64 };   export fn main() void = { for (let y = -1.2; y < 1.2; y += 0.05) { for (let x = -2.05; x < 0.55; x += 0.03) { let z = complex {re = 0.0, im = 0.0};   for (let m = 0z; m < 100; m += 1) { let tz = z;   z.re = tz.re*tz.re - tz.im*tz.im; ...
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#VTL-2
VTL-2
10 N=1 20 ?="Magic square of order "; 30 ?=N 40 ?=" with constant "; 50 ?=N*N+1/2*N 60 ?=":" 70 Y=0 80 X=0 90 ?=Y*2+N-X/N*0+%*N+(Y*2+X+1/N*0+%+1 100 $=9 110 X=X+1 120 #=X<N*90 130 ?="" 140 Y=Y+1 150 #=Y<N*80 160 ?="" 170 N=N+2 180 #=7>N*20
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#Wren
Wren
import "/fmt" for Fmt   var ms = Fn.new { |n| var M = Fn.new { |x| (x + n - 1) % n } if (n <= 0 || n&1 == 0) { n = 5 System.print("forcing size %(n)") } var m = List.filled(n * n, 0) var i = 0 var j = (n/2).floor for (k in 1..n*n) { m[i*n + j] = k if (m[M.call...
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.
#Lambdatalk
Lambdatalk
  {require lib_matrix}   1) applying a matrix to a vector   {def M {M.new [[1,2,3], [4,5,6], [7,8,-9]]}} -> M   {def V {M.new [1,2,3]} } -> V   {M.multiply {M} {V}} -> [14,32,-4]   2) matrix multiplication   {M.multiply {M} {M}} -> [[ 30, 36,-12], [ 66, 81,-12], [-24,-18,150]]  
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Klong
Klong
[5 5]:^!25 [[0 1 2 3 4] [5 6 7 8 9] [10 11 12 13 14] [15 16 17 18 19] [20 21 22 23 24]]   +[5 5]:^!25 [[0 5 10 15 20] [1 6 11 16 21] [2 7 12 17 22] [3 8 13 18 23] [4 9 14 19 24]]
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#Swift
Swift
import Foundation   extension Array { mutating func shuffle() { guard count > 1 else { return }   for i in 0..<self.count - 1 { let j = Int(arc4random_uniform(UInt32(count - i))) + i guard i != j else { continue } swap(&self[i], &self[j]) } } }   enum ...
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#RLaB
RLaB
>> x = "The quick brown fox jumped over the lazy dog's back" The quick brown fox jumped over the lazy dog's back   >> hash("md5", x) e38ca1d920c4b8b8d3946b2c72f01680
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 .
#Haskell
Haskell
import Data.Bool import Data.Complex (Complex((:+)), magnitude)   mandelbrot :: RealFloat a => Complex a -> Complex a mandelbrot a = iterate ((a +) . (^ 2)) 0 !! 50   main :: IO () main = mapM_ putStrLn [ [ bool ' ' '*' (2 > magnitude (mandelbrot (x :+ y))) | x <- [-2,-1.9685 .. 0.5] ] | y <- [1...
http://rosettacode.org/wiki/Magic_squares_of_odd_order
Magic squares of odd order
A magic square is an   NxN   square matrix whose numbers (usually integers) consist of consecutive numbers arranged so that the sum of each row and column,   and   both long (main) diagonals are equal to the same sum (which is called the   magic number   or   magic constant). The numbers are usually (but not always) t...
#zkl
zkl
fcn rmod(n,m){ n=n%m; if (n<0) n+=m; n } // Ruby: -5%3-->1 fcn odd_magic_square(n){ //-->list of n*n numbers, row order if (n.isEven or n <= 0) throw(Exception.ValueError("Need odd positive number")); [[(i,j); n; n; '{ n*((i+j+1+n/2):rmod(_,n)) + ((i+2*j-5):rmod(_,n)) + 1 }]] }   T(3, 5, 9).pump(Void,fcn(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.
#Lang5
Lang5
[[1 2 3] [4 5 6]] 'm dress [[1 2] [3 4] [5 6]] 'm dress * .
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Kotlin
Kotlin
// version 1.1.3   typealias Vector = DoubleArray typealias Matrix = Array<Vector>   fun Matrix.transpose(): Matrix { val rows = this.size val cols = this[0].size val trans = Matrix(cols) { Vector(rows) } for (i in 0 until cols) { for (j in 0 until rows) trans[i][j] = this[j][i] } return...
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#Tcl
Tcl
package require TclOO; # Or Tcl 8.6   # Helper to pick a random number proc rand n {expr {int(rand() * $n)}} # Helper to pick a random element of a list proc pick list {lindex $list [rand [llength $list]]} # Helper _function_ to index into a list of lists proc tcl::mathfunc::idx {v x y} {lindex $v $x $y}   oo::class cr...
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#RPG
RPG
**FREE Ctl-opt MAIN(Main); Ctl-opt DFTACTGRP(*NO) ACTGRP(*NEW);   dcl-pr QDCXLATE EXTPGM('QDCXLATE'); dataLen packed(5 : 0) CONST; data char(32767) options(*VARSIZE); conversionTable char(10) CONST; end-pr;   dcl-pr Qc3CalculateHash EXTPROC('Qc3CalculateHash'); inputData pointer v...
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 .
#Haxe
Haxe
haxe -swf mandelbrot.swf -main Mandelbrot
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.
#LFE
LFE
  (defun matrix* (matrix-1 matrix-2) (list-comp ((<- a matrix-1)) (list-comp ((<- b (transpose matrix-2))) (lists:foldl #'+/2 0 (lists:zipwith #'*/2 a b)))))  
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Lang5
Lang5
12 iota [3 4] reshape 1 + dup . 1 transpose .
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#TXR
TXR
@(bind (width height) (15 15)) @(do (defvar *r* (make-random-state nil)) (defvar vi) (defvar pa)   (defun neigh (loc) (let ((x (from loc)) (y (to loc))) (list (- x 1)..y (+ x 1)..y x..(- y 1) x..(+ y 1))))   (defun make-maze-rec (cu) (set [vi cu] t) (each ((n...
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#Ruby
Ruby
require 'digest' Digest::MD5.hexdigest("The quick brown fox jumped over the lazy dog's back") # => "e38ca1d920c4b8b8d3946b2c72f01680"
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 .
#Huginn
Huginn
#! /bin/sh exec huginn -E "${0}" "${@}" #! huginn   import Algorithms as algo; import Mathematics as math; import Terminal as term;   mandelbrot( x, y ) { c = math.Complex( x, y ); z = math.Complex( 0., 0. ); s = -1; for ( i : algo.range( 50 ) ) { z = z * z + c; if ( | z | > 2. ) { s = i; br...
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.
#Liberty_BASIC
Liberty BASIC
  MatrixA$ ="4, 4, 1, 1, 1, 1, 2, 4, 8, 16, 3, 9, 27, 81, 4, 16, 64, 256" MatrixB$ ="4, 4, 4, -3, 4/3, -1/4 , -13/3, 19/4, -7/3, 11/24, 3/2, -2, 7/6, -1/4, -1/6, 1/4, -1/6, 1/24"   print "Product of two matrices" call DisplayMatrix MatrixA$ print " *"...
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#LFE
LFE
  (defun transpose (matrix) (transpose matrix '()))   (defun transpose (matrix acc) (cond ((lists:any (lambda (x) (== x '())) matrix) acc) ('true (let ((heads (lists:map #'car/1 matrix)) (tails (lists:map #'cdr/1 matrix))) (transpose tails (++ acc `(,heads)))))...
http://rosettacode.org/wiki/Maze_generation
Maze generation
This page uses content from Wikipedia. The original article was at Maze generation algorithm. 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) Task Generate and show a maze, using the simple Depth...
#XPL0
XPL0
code Ran=1, CrLf=9, Text=12; \intrinsic routines def Cols=20, Rows=6; \dimensions of maze (cells) int Cell(Cols+1, Rows+1, 3); \cells (plus right and bottom borders) def LeftWall, Ceiling, Connected; \attributes of each cell (= 0, 1 and 2)   proc ConnectFrom(X, Y); ...
http://rosettacode.org/wiki/MD5
MD5
Task Encode a string using an MD5 algorithm.   The algorithm can be found on   Wikipedia. Optionally, validate your implementation by running all of the test values in   IETF RFC (1321)   for MD5. Additionally,   RFC 1321   provides more precise information on the algorithm than the Wikipedia article. Warning:...
#Rust
Rust
  [dependencies] rust-crypto = "0.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 .
#Icon_and_Unicon
Icon and Unicon
link graphics   procedure main() width := 750 height := 600 limit := 100 WOpen("size="||width||","||height) every x:=1 to width & y:=1 to height do { z:=complex(0,0) c:=complex(2.5*x/width-2.0,(2.0*y/height-1.0)) j:=0 while j<limit & cAbs(z)<2.0 do { ...
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.
#Logo
Logo
TO LISTVMD :A :F :C :NV ;PROCEDURE LISTVMD ;A = LIST ;F = ROWS ;C = COLS ;NV = NAME OF MATRIX / VECTOR NEW ;this procedure transform a list in matrix / vector square or rect   (LOCAL "CF "CC "NV "T "W) MAKE "CF 1 MAKE "CC 1 MAKE "NV (MDARRAY (LIST :F :C) 1) MAKE "T :F * :C FOR [Z 1 :T][MAKE "W ITEM :Z :A MDSETITEM (LIS...
http://rosettacode.org/wiki/Matrix_transposition
Matrix transposition
Transpose an arbitrarily sized rectangular Matrix.
#Liberty_BASIC
Liberty BASIC
MatrixC$ ="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 MatrixC$ print " =" MatrixT$ =MatrixTranspose$( MatrixC$) call DisplayMatrix MatrixT$