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/Regular_expressions
Regular expressions
Task   match a string against a regular expression   substitute part of a string using a regular expression
#Vala
Vala
  void main(){ string sentence = "This is a sample sentence.";   Regex a = new Regex("s[ai]mple"); // if using \n type expressions, use triple " for string literals as easy method to escape them   if (a.match(sentence)){ stdout.printf("\"%s\" is in \"%s\"!\n", a.get_pattern...
http://rosettacode.org/wiki/Reverse_a_string
Reverse a string
Task Take a string and reverse it. For example, "asdf" becomes "fdsa". Extra credit Preserve Unicode combining characters. For example, "as⃝df̅" becomes "f̅ds⃝a", not "̅fd⃝sa". Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting ...
#Elm
Elm
-- The import on the next line provides the reverse string -- functionality satisfying the rosettacode.org task description. import String exposing (reverse)   -- The rest is fairly boilerplate code demonstrating -- interactively that the reverse function works. import Html exposing (Html, Attribute, text, div, input...
http://rosettacode.org/wiki/Reverse_words_in_a_string
Reverse words in a string
Task Reverse the order of all tokens in each of a number of strings and display the result;   the order of characters within a token should not be modified. Example Hey you, Bub!   would be shown reversed as:   Bub! you, Hey Tokens are any non-space characters separated by spaces (formally, white-space);   t...
#TXR
TXR
txr reverse.txr verse.txt
http://rosettacode.org/wiki/Rot-13
Rot-13
Task Implement a   rot-13   function   (or procedure, class, subroutine, or other "callable" object as appropriate to your programming environment). Optionally wrap this function in a utility program   (like tr,   which acts like a common UNIX utility, performing a line-by-line rot-13 encoding of every line of inpu...
#XPL0
XPL0
code ChIn=7, ChOut=8; int C, CC; repeat C:= ChIn(1); CC:= C&~$20; \CC handles lowercase too ChOut(0, C + (if CC>=^A & CC<=^M then +13 else if CC>=^N & CC<=^Z then -13 else 0)); until C = $1A; \EOF
http://rosettacode.org/wiki/Roman_numerals/Encode
Roman numerals/Encode
Task Create a function taking a positive integer as its parameter and returning a string containing the Roman numeral representation of that integer. Modern Roman numerals are written by expressing each digit separately, starting with the left most digit and skipping any digit with a value of zero. In Roman numeral...
#XBasic
XBasic
  PROGRAM "romanenc" VERSION "0.0000"   DECLARE FUNCTION Entry() INTERNAL FUNCTION ToRoman$(aValue%%)   ' 3888 or MMMDCCCLXXXVIII (15 chars) is the longest string properly encoded with these symbols.   FUNCTION Entry() PRINT ToRoman$(1990) ' MCMXC PRINT ToRoman$(2018) ' MMXVIII PRINT ToRoman$(3888) ' MMMDCCCLXXXV...
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#Mercury
Mercury
:- module repeat. :- interface. :- import_module string, char, int.   :- func repeat_char(char, int) = string. :- func repeat(string, int) = string.   :- implementation. :- import_module stream, stream.string_writer, string.builder.   repeat_char(C, N) = string.duplicate_char(C, N).   repeat(String, Count) = Repeated :...
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#min
min
"ha" 5 repeat print
http://rosettacode.org/wiki/Remove_duplicate_elements
Remove duplicate elements
Sorting Algorithm This is a sorting algorithm.   It may be applied to a set of data in order to sort it.     For comparing various sorts, see compare sorts.   For other sorting algorithms,   see sorting algorithms,   or: O(n logn) sorts Heap sort | Merge sort | Patience sort | Quick sort O(n log2n) sorts Shell Sort ...
#Julia
Julia
a = [1, 2, 3, 4, 1, 2, 3, 4] @show unique(a) Set(a)
http://rosettacode.org/wiki/Reduced_row_echelon_form
Reduced row echelon form
Reduced row echelon form You are encouraged to solve this task according to the task description, using any language you may know. Task Show how to compute the reduced row echelon form (a.k.a. row canonical form) of a matrix. The matrix can be stored in any datatype that is convenient (for most languages, this wil...
#Racket
Racket
  #lang racket (require math) (define (reduced-echelon M) (matrix-row-echelon M #t #t))   (reduced-echelon (matrix [[1 2 -1 -4] [2 3 -1 -11] [-2 0 -3 22]]))  
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#.D0.9C.D0.9A-61.2F52
МК-61/52
1 e^x С/П   пи С/П   КвКор С/П   lg С/П   e^x С/П   |x| С/П   П0 ^ [x] П1 - x=0 09 ИП0 С/П ЗН x>=0 14 ИП1 С/П ИП1 1 - С/П   П0 ^ [x] П1 - x=0 09 ИП0 С/П ЗН x<0 14 ИП1 С/П ИП1 1 + С/П   x^y С/П
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#Modula-3
Modula-3
Math.E; Math.Pi; Math.sqrt(x); Math.log(x); Math.exp(x); ABS(x); (* Built in function. *) FLOOR(x); (* Built in function. *) CEILING(x); (* Built in function. *) Math.pow(x, y);
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#PARI.2FGP
PARI/GP
str = concat(apply(s->concat(s,"\n"), readstr("file.txt")))
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#Pascal
Pascal
perl -n -0777 -e 'print "file len: ".length' stuff.txt
http://rosettacode.org/wiki/Regular_expressions
Regular expressions
Task   match a string against a regular expression   substitute part of a string using a regular expression
#VBScript
VBScript
text = "I need more coffee!!!" Set regex = New RegExp regex.Global = True regex.Pattern = "\s" If regex.Test(text) Then WScript.StdOut.Write regex.Replace(text,vbCrLf) Else WScript.StdOut.Write "No matching pattern" End If
http://rosettacode.org/wiki/Regular_expressions
Regular expressions
Task   match a string against a regular expression   substitute part of a string using a regular expression
#Vedit_macro_language
Vedit macro language
if (Match(".* string$", REGEXP)==0) { Statline_Message("This line ends with 'string'") }
http://rosettacode.org/wiki/Reverse_a_string
Reverse a string
Task Take a string and reverse it. For example, "asdf" becomes "fdsa". Extra credit Preserve Unicode combining characters. For example, "as⃝df̅" becomes "f̅ds⃝a", not "̅fd⃝sa". Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting ...
#Emacs_Lisp
Emacs Lisp
(reverse "Hello World")
http://rosettacode.org/wiki/Reverse_words_in_a_string
Reverse words in a string
Task Reverse the order of all tokens in each of a number of strings and display the result;   the order of characters within a token should not be modified. Example Hey you, Bub!   would be shown reversed as:   Bub! you, Hey Tokens are any non-space characters separated by spaces (formally, white-space);   t...
#UNIX_Shell
UNIX Shell
while read -a words; do for ((i=${#words[@]}-1; i>=0; i--)); do printf "%s " "${words[i]}" done echo done << END ---------- Ice and Fire ------------   fire, in end will world the say Some ice. in say Some desire of tasted I've what From fire. favor who those with hold I   ... ...
http://rosettacode.org/wiki/Reverse_words_in_a_string
Reverse words in a string
Task Reverse the order of all tokens in each of a number of strings and display the result;   the order of characters within a token should not be modified. Example Hey you, Bub!   would be shown reversed as:   Bub! you, Hey Tokens are any non-space characters separated by spaces (formally, white-space);   t...
#VBA
VBA
  Option Explicit   Sub Main() Dim Lines(9) As String, i& 'Input Lines(0) = "------------- Ice And Fire -------------" Lines(1) = "" Lines(2) = "fire, in end will world the say Some" Lines(3) = "ice. in say Some" Lines(4) = "desire of tasted I've what From" Lines(5) = "fire. favor who those ...
http://rosettacode.org/wiki/Rot-13
Rot-13
Task Implement a   rot-13   function   (or procedure, class, subroutine, or other "callable" object as appropriate to your programming environment). Optionally wrap this function in a utility program   (like tr,   which acts like a common UNIX utility, performing a line-by-line rot-13 encoding of every line of inpu...
#XSLT
XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" /> <xsl:variable name="alpha">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz</xsl:variable> <xsl:variable name="rot13">NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm</xsl:variable> <xsl:templa...
http://rosettacode.org/wiki/Roman_numerals/Encode
Roman numerals/Encode
Task Create a function taking a positive integer as its parameter and returning a string containing the Roman numeral representation of that integer. Modern Roman numerals are written by expressing each digit separately, starting with the left most digit and skipping any digit with a value of zero. In Roman numeral...
#XLISP
XLISP
(defun roman (n) (define roman-numerals '((1000 "m") (900 "cm") (500 "d") (400 "cd") (100 "c") (90 "xc") (50 "l") (40 "xl") (10 "x") (9 "ix") (5 "v") (4 "iv") (1 "i"))) (defun romanize (arabic-numeral numerals roman-numeral) (if (= arabic-numeral 0) roman-numeral (if (>= arabic-n...
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#MiniScript
MiniScript
str = "Lol" print str * 5
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#Mirah
Mirah
x = StringBuilder.new   5.times do x.append "ha" end   puts x # ==> "hahahahaha"
http://rosettacode.org/wiki/Remove_duplicate_elements
Remove duplicate elements
Sorting Algorithm This is a sorting algorithm.   It may be applied to a set of data in order to sort it.     For comparing various sorts, see compare sorts.   For other sorting algorithms,   see sorting algorithms,   or: O(n logn) sorts Heap sort | Merge sort | Patience sort | Quick sort O(n log2n) sorts Shell Sort ...
#K
K
a:4 5#20?13 / create a random 4 x 5 matrix (12 7 12 4 3 6 3 7 4 7 3 8 3 1 2 2 12 6 4 1)   ,/a / flatten to array 12 7 12 4 3 6 3 7 4 7 3 8 3 1 2 2 12 6 4 1    ?,/a / distinct elements 12 7 4 3 6 8 1 2    ?"chthonic eleemosynary paronomasiac" "chtoni elmsyarp"    ?("this";"that";"was"...
http://rosettacode.org/wiki/Remove_duplicate_elements
Remove duplicate elements
Sorting Algorithm This is a sorting algorithm.   It may be applied to a set of data in order to sort it.     For comparing various sorts, see compare sorts.   For other sorting algorithms,   see sorting algorithms,   or: O(n logn) sorts Heap sort | Merge sort | Patience sort | Quick sort O(n log2n) sorts Shell Sort ...
#Klingphix
Klingphix
( )   ( "Now" "is" "the" "time" "for" "all" "good" "men" "to" "come" "to" "the" "aid" "of" "the" "party." )   len [ get rot over find not ( [swap 0 put] [nip] ) if swap ] for   swap print drop nl   "End " input
http://rosettacode.org/wiki/Reduced_row_echelon_form
Reduced row echelon form
Reduced row echelon form You are encouraged to solve this task according to the task description, using any language you may know. Task Show how to compute the reduced row echelon form (a.k.a. row canonical form) of a matrix. The matrix can be stored in any datatype that is convenient (for most languages, this wil...
#Raku
Raku
sub rref (@m) { my ($lead, $rows, $cols) = 0, @m, @m[0]; for ^$rows -> $r { return @m unless $lead < $cols; my $i = $r; until @m[$i;$lead] { next unless ++$i == $rows; $i = $r; return @m if ++$lead == $cols; } @m[$i, $r] = @m[$r, $i] if...
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#Neko
Neko
/** Real constants and functions, in Neko Tectonics: nekoc real-constants.neko neko real-constants */   var euler = $loader.loadprim("std@math_exp", 1)(1) var pi = $loader.loadprim("std@math_pi", 0)()   var math_sqrt = $loader.loadprim("std@math_sqrt", 1) var math_log = $loader.loadprim("std@math_log", 1) var m...
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#Perl
Perl
perl -n -0777 -e 'print "file len: ".length' stuff.txt
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#Phix
Phix
?get_text(command_line()[2])
http://rosettacode.org/wiki/Regular_expressions
Regular expressions
Task   match a string against a regular expression   substitute part of a string using a regular expression
#Web_68
Web 68
@1Introduction. Web 68 has access to a regular expression module which can compile regular expressions, use them for matching strings, and replace strings with the matched string.   @a@<Compiler prelude@> BEGIN @<Declarations@> @<Logic at the top level@> END @<Compiler postlude@>   @ The local compiler requires a spe...
http://rosettacode.org/wiki/Regular_expressions
Regular expressions
Task   match a string against a regular expression   substitute part of a string using a regular expression
#Wren
Wren
import "/pattern" for Pattern   var s = "This is a story about R2D2 and C3P0 who are best friends." var p = Pattern.new("/u/d/u/d") var matches = p.findAll(s) System.print("Original string:\n%(" %(s)")")   System.print("\nThe following matches were found:") matches.each{ |m| System.print("  %(m.text) at index %(m.inde...
http://rosettacode.org/wiki/Reverse_a_string
Reverse a string
Task Take a string and reverse it. For example, "asdf" becomes "fdsa". Extra credit Preserve Unicode combining characters. For example, "as⃝df̅" becomes "f̅ds⃝a", not "̅fd⃝sa". Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting ...
#Erlang
Erlang
1> lists:reverse("reverse!"). "!esrever"
http://rosettacode.org/wiki/Reverse_words_in_a_string
Reverse words in a string
Task Reverse the order of all tokens in each of a number of strings and display the result;   the order of characters within a token should not be modified. Example Hey you, Bub!   would be shown reversed as:   Bub! you, Hey Tokens are any non-space characters separated by spaces (formally, white-space);   t...
#VBScript
VBScript
  Option Explicit   Dim objFSO, objInFile, objOutFile Dim srcDir, line   Set objFSO = CreateObject("Scripting.FileSystemObject")   srcDir = objFSO.GetParentFolderName(WScript.ScriptFullName) & "\"   Set objInFile = objFSO.OpenTextFile(srcDir & "In.txt",1,False,0)   Set objOutFile = objFSO.OpenTextFile(srcDir & "Out.txt...
http://rosettacode.org/wiki/Rot-13
Rot-13
Task Implement a   rot-13   function   (or procedure, class, subroutine, or other "callable" object as appropriate to your programming environment). Optionally wrap this function in a utility program   (like tr,   which acts like a common UNIX utility, performing a line-by-line rot-13 encoding of every line of inpu...
#Yabasic
Yabasic
  s$ = "nowhere ABJURER" print " Cadena original : ", s$ print " Tras codificar : ", Rot13$(s$) print "Tras decodificar : ", Rot13$(Rot13$(s$)) end   sub Rot13$ (s$) local cad$ cad$ = ""   for i = 1 to len(s$) temp = asc(mid$(s$, i, 1))   if temp >= 65 and temp <= 90 then // A to Z ...
http://rosettacode.org/wiki/Roman_numerals/Encode
Roman numerals/Encode
Task Create a function taking a positive integer as its parameter and returning a string containing the Roman numeral representation of that integer. Modern Roman numerals are written by expressing each digit separately, starting with the left most digit and skipping any digit with a value of zero. In Roman numeral...
#XPL0
XPL0
proc Rom(N, A, B, C); \Display 1..9 in Roman numerals int N, A, B, C, I; [case N of 9: [ChOut(0, C); ChOut(0, A)]; \XI 8,7,6,5:[ChOut(0, B); for I:= 1 to rem(N/5) do ChOut(0, C)]; \V 4: [ChOut(0, C); ChOut(0, B)] \IV other for I:= 1 t...
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#Monte
Monte
  var s := "ha " * 5 traceln(s)  
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#MontiLang
MontiLang
|ha| 5 * PRINT .
http://rosettacode.org/wiki/Remove_duplicate_elements
Remove duplicate elements
Sorting Algorithm This is a sorting algorithm.   It may be applied to a set of data in order to sort it.     For comparing various sorts, see compare sorts.   For other sorting algorithms,   see sorting algorithms,   or: O(n logn) sorts Heap sort | Merge sort | Patience sort | Quick sort O(n log2n) sorts Shell Sort ...
#Kotlin
Kotlin
fun main(args: Array<String>) { val data = listOf(1, 2, 3, "a", "b", "c", 2, 3, 4, "b", "c", "d") val set = data.distinct()   println(data) println(set) }
http://rosettacode.org/wiki/Reduced_row_echelon_form
Reduced row echelon form
Reduced row echelon form You are encouraged to solve this task according to the task description, using any language you may know. Task Show how to compute the reduced row echelon form (a.k.a. row canonical form) of a matrix. The matrix can be stored in any datatype that is convenient (for most languages, this wil...
#REXX
REXX
/*REXX pgm performs Reduced Row Echelon Form (RREF), AKA row canonical form on a matrix)*/ cols= 0; w= 0; @. =0 /*max cols in a row; max width; matrix.*/ mat.=; mat.1= ' 1 2 -1 -4 ' mat.2= ' 2 3 -1 -11 ' ...
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#NetRexx
NetRexx
/* NetRexx */ options replace format comments java crossref symbols nobinary utf8   numeric digits 30   x = 2.5 y = 3 pad = 40 say say 'Java Math constants & functions:' say Rexx(' Euler''s number (e):').left(pad) Math.E say Rexx(' Pi:').left(pad) Math.PI say Rex...
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#PHP
PHP
file_get_contents($filename)
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#Picat
Picat
  main(Args) => File = Args[1], String = read_file_chars(File).  
http://rosettacode.org/wiki/Regular_expressions
Regular expressions
Task   match a string against a regular expression   substitute part of a string using a regular expression
#zkl
zkl
var re=RegExp(".*string$"); re.matches("I am a string") //-->True var s="I am a string thing" re=RegExp("(string)") // () means group, ie if you see it, save it re.search(s,True) //-->True, .search(x,True) means search for a match, ie don't need .* p,n:=re.matched[0] //.matched-->L(L(7,6),"string") String(s[0,p],"FOO"...
http://rosettacode.org/wiki/Reverse_a_string
Reverse a string
Task Take a string and reverse it. For example, "asdf" becomes "fdsa". Extra credit Preserve Unicode combining characters. For example, "as⃝df̅" becomes "f̅ds⃝a", not "̅fd⃝sa". Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting ...
#ERRE
ERRE
  PROGRAM REVERSE_STRING   PROCEDURE REVERSE(A$->R$) LOCAL I% R$="" FOR I=1 TO LEN(A$) DO R$=MID$(A$,I,1)+R$ END FOR END PROCEDURE   BEGIN A$="THE FIVE BOXING WIZARDS JUMP QUICKLY" REVERSE(A$->R$) PRINT(R$) END PROGRAM  
http://rosettacode.org/wiki/Reverse_words_in_a_string
Reverse words in a string
Task Reverse the order of all tokens in each of a number of strings and display the result;   the order of characters within a token should not be modified. Example Hey you, Bub!   would be shown reversed as:   Bub! you, Hey Tokens are any non-space characters separated by spaces (formally, white-space);   t...
#Vlang
Vlang
fn main() { mut n := [ "---------- Ice and Fire ------------", " ", "fire, in end will world the say Some", "ice. in say Some ", "desire of tasted I've what From ", "fire. favor who those with hold I ", ...
http://rosettacode.org/wiki/Reverse_words_in_a_string
Reverse words in a string
Task Reverse the order of all tokens in each of a number of strings and display the result;   the order of characters within a token should not be modified. Example Hey you, Bub!   would be shown reversed as:   Bub! you, Hey Tokens are any non-space characters separated by spaces (formally, white-space);   t...
#Wren
Wren
var lines = [ "---------- Ice and Fire ------------", " ", "fire, in end will world the say Some", "ice. in say Some ", "desire of tasted I've what From ", "fire. favor who those with hold I ", " ...
http://rosettacode.org/wiki/Rot-13
Rot-13
Task Implement a   rot-13   function   (or procedure, class, subroutine, or other "callable" object as appropriate to your programming environment). Optionally wrap this function in a utility program   (like tr,   which acts like a common UNIX utility, performing a line-by-line rot-13 encoding of every line of inpu...
#zig
zig
  // Warning: modifies the buffer in-place (returns pointer to in) fn rot13(in: [] u8) []u8 { for (in) |*c| { var d : u8 = c.*; var x : u8 = d; x = if (@subWithOverflow(u8, d | 32, 97, &x) ) x else x; if (x < 26) { x = (x + 13) % 26 + 65 + (d & 32); c.* = x; ...
http://rosettacode.org/wiki/Roman_numerals/Encode
Roman numerals/Encode
Task Create a function taking a positive integer as its parameter and returning a string containing the Roman numeral representation of that integer. Modern Roman numerals are written by expressing each digit separately, starting with the left most digit and skipping any digit with a value of zero. In Roman numeral...
#XSLT
XSLT
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/data/number"> <xsl:call-template name="for"> <xsl:with-param name="stop">13</xsl:with-param> <xsl:with-param name="value"><xsl:value-of select="@value"></xsl:value-of></xsl:wit...
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#MUMPS
MUMPS
RPTSTR(S,N)  ;Repeat a string S for N times NEW I FOR I=1:1:N WRITE S KILL I QUIT RPTSTR1(S,N) ;Functionally equivalent, but denser to read F I=1:1:N W S Q  
http://rosettacode.org/wiki/Remove_duplicate_elements
Remove duplicate elements
Sorting Algorithm This is a sorting algorithm.   It may be applied to a set of data in order to sort it.     For comparing various sorts, see compare sorts.   For other sorting algorithms,   see sorting algorithms,   or: O(n logn) sorts Heap sort | Merge sort | Patience sort | Quick sort O(n log2n) sorts Shell Sort ...
#Lang5
Lang5
: dip swap '_ set execute _ ;   : remove-duplicates [] swap do unique? length 0 == if break then loop drop ; : unique? 0 extract swap "2dup in if drop else append then" dip ;   [1 2 6 3 6 4 5 6] remove-duplicates .
http://rosettacode.org/wiki/Reduced_row_echelon_form
Reduced row echelon form
Reduced row echelon form You are encouraged to solve this task according to the task description, using any language you may know. Task Show how to compute the reduced row echelon form (a.k.a. row canonical form) of a matrix. The matrix can be stored in any datatype that is convenient (for most languages, this wil...
#Ring
Ring
  # Project : Reduced row echelon form   matrix = [[1, 2, -1, -4], [2, 3, -1, -11], [ -2, 0, -3, 22]] ref(matrix) for row = 1 to 3 for col = 1 to 4 if matrix[row][col] = -0 see "0 " else see "" + matrix[row][col] + " " ok ...
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#Nim
Nim
import math   var x, y = 12.5   echo E echo PI echo sqrt(x) echo ln(x) echo log10(x) echo exp(x) echo abs(x) echo floor(x) echo ceil(x) echo pow(x, y)
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#Objeck
Objeck
Float->Pi(); Float->E(); 4.0->SquareRoot(); 1.5->Log(); # exponential is not supported 3.99->Abs(); 3.99->Floor(); 3.99->Ceiling(); 4.5->Ceiling(2.0);
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#PicoLisp
PicoLisp
(in "file" (till NIL T))
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#Pike
Pike
string content=Stdio.File("foo.txt")->read();
http://rosettacode.org/wiki/Reverse_a_string
Reverse a string
Task Take a string and reverse it. For example, "asdf" becomes "fdsa". Extra credit Preserve Unicode combining characters. For example, "as⃝df̅" becomes "f̅ds⃝a", not "̅fd⃝sa". Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting ...
#Euler_Math_Toolbox
Euler Math Toolbox
  >function strrev (s) := chartostr(fliplr(strtochar(s))) >strrev("This is a test!")  !tset a si sihT  
http://rosettacode.org/wiki/Reverse_words_in_a_string
Reverse words in a string
Task Reverse the order of all tokens in each of a number of strings and display the result;   the order of characters within a token should not be modified. Example Hey you, Bub!   would be shown reversed as:   Bub! you, Hey Tokens are any non-space characters separated by spaces (formally, white-space);   t...
#XBS
XBS
func revWords(x:string=""){ (x=="")&=>send x+"<br>"; set sp = x::split(" "); send sp::reverse()::join(" "); }   set lines:array=[ "---------- Ice and Fire ------------", "", "fire, in end will world the say Some", "ice. in say Some", "desire of tasted I've what From", "fire. favor who those with hold I", "", ...
http://rosettacode.org/wiki/Reverse_words_in_a_string
Reverse words in a string
Task Reverse the order of all tokens in each of a number of strings and display the result;   the order of characters within a token should not be modified. Example Hey you, Bub!   would be shown reversed as:   Bub! you, Hey Tokens are any non-space characters separated by spaces (formally, white-space);   t...
#XPL0
XPL0
string 0; def LF=$0A, CR=$0D;   proc Reverse(Str, Len); \Reverse order of chars in string char Str; int Len; int I, J, T; [I:= 0; J:= Len-1; while I < J do [T:= Str(I); Str(I):= Str(J); Str(J):= T; I:= I+1; J:= J-1; ]; ];   char Str; int I, LineBase, WordBase; [Str:= "---------- Ice and Fire ---------...
http://rosettacode.org/wiki/Rot-13
Rot-13
Task Implement a   rot-13   function   (or procedure, class, subroutine, or other "callable" object as appropriate to your programming environment). Optionally wrap this function in a utility program   (like tr,   which acts like a common UNIX utility, performing a line-by-line rot-13 encoding of every line of inpu...
#zkl
zkl
#!/home/craigd/Bin/zkl fcn rot13(text){ text.translate("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"); } text:=(vm.arglist or File.stdin); // command line or pipe text.pump(File.stdout,rot13); // rotate each word and print it if(text.isTyp...
http://rosettacode.org/wiki/Roman_numerals/Encode
Roman numerals/Encode
Task Create a function taking a positive integer as its parameter and returning a string containing the Roman numeral representation of that integer. Modern Roman numerals are written by expressing each digit separately, starting with the left most digit and skipping any digit with a value of zero. In Roman numeral...
#Yabasic
Yabasic
roman$ = "M, CM, D, CD, C, XC, L, XL, X, IX, V, IV, I" decml$ = "1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1"   sub toRoman$(value) local res$, i, roman$(1), decml$(1), long   long = token(roman$, roman$(), ", ") long = token(decml$, decml$(), ", ")   for i=1 to long while(value ...
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#Nanoquery
Nanoquery
"ha" * 5
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#Neko
Neko
/* Repeat a string, in Neko */ var srep = function(s, n) { var str = "" while n > 0 { str += s n -= 1 } return str }   $print(srep("ha", 5), "\n")
http://rosettacode.org/wiki/Remove_duplicate_elements
Remove duplicate elements
Sorting Algorithm This is a sorting algorithm.   It may be applied to a set of data in order to sort it.     For comparing various sorts, see compare sorts.   For other sorting algorithms,   see sorting algorithms,   or: O(n logn) sorts Heap sort | Merge sort | Patience sort | Quick sort O(n log2n) sorts Shell Sort ...
#Lasso
Lasso
local( x = array(3,4,8,1,8,1,4,5,6,8,9,6), y = array ) with n in #x where #y !>> #n do => { #y->insert(#n) } // result: array(3, 4, 8, 1, 5, 6, 9)
http://rosettacode.org/wiki/Remove_duplicate_elements
Remove duplicate elements
Sorting Algorithm This is a sorting algorithm.   It may be applied to a set of data in order to sort it.     For comparing various sorts, see compare sorts.   For other sorting algorithms,   see sorting algorithms,   or: O(n logn) sorts Heap sort | Merge sort | Patience sort | Quick sort O(n log2n) sorts Shell Sort ...
#Liberty_BASIC
Liberty BASIC
  a$ =" 1 $23.19 2 elbow 3 2 Bork 4 3 elbow 2 $23.19 " print "Original set of elements = ["; a$; "]"   b$ =removeDuplicates$( a$) print "With duplicates removed = ["; b$; "]"   end   function removeDuplicates$( in$) o$ =" " i =1 do term$ =word$( in$, i, " ") if instr( o$, " "; term$; " ...
http://rosettacode.org/wiki/Reduced_row_echelon_form
Reduced row echelon form
Reduced row echelon form You are encouraged to solve this task according to the task description, using any language you may know. Task Show how to compute the reduced row echelon form (a.k.a. row canonical form) of a matrix. The matrix can be stored in any datatype that is convenient (for most languages, this wil...
#Ruby
Ruby
# returns an 2-D array where each element is a Rational def reduced_row_echelon_form(ary) lead = 0 rows = ary.size cols = ary[0].size rary = convert_to(ary, :to_r) # use rational arithmetic catch :done do rows.times do |r| throw :done if cols <= lead i = r while rary[i][lead] == 0 ...
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#OCaml
OCaml
Float.pi (* pi *) sqrt x (* square root *) log x (* natural logarithm--log base 10 also available (log10) *) exp x (* exponential *) abs_float x (* absolute value *) abs x (* absolute value (for integers) *) floor x (* floor *) ceil x (* ceiling *) x ** y (* power *) -. x ...
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#Octave
Octave
e % e pi % pi sqrt(pi) % square root log(e) % natural logarithm exp(pi) % exponential abs(-e) % absolute value floor(pi) % floor ceil(pi) % ceiling e**pi % power
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#PL.2FI
PL/I
  get file (in) edit ((substr(s, i, 1) do i = 1 to 32767)) (a);  
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#PowerShell
PowerShell
Get-Content foo.txt
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#Prolog
Prolog
  :- initialization(main).   main :- current_prolog_flag(argv, [File|_]), read_file_to_string(File, String, []).  
http://rosettacode.org/wiki/Reverse_a_string
Reverse a string
Task Take a string and reverse it. For example, "asdf" becomes "fdsa". Extra credit Preserve Unicode combining characters. For example, "as⃝df̅" becomes "f̅ds⃝a", not "̅fd⃝sa". Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting ...
#Euphoria
Euphoria
  include std/sequence.e printf(1, "%s\n", {reverse("abcdef") })  
http://rosettacode.org/wiki/Reverse_words_in_a_string
Reverse words in a string
Task Reverse the order of all tokens in each of a number of strings and display the result;   the order of characters within a token should not be modified. Example Hey you, Bub!   would be shown reversed as:   Bub! you, Hey Tokens are any non-space characters separated by spaces (formally, white-space);   t...
#Yabasic
Yabasic
data " ---------- Ice and Fire ------------ " data " " data " fire, in end will world the say Some " data " ice. in say Some " data " desire of tasted I've what From " data " fire. favor who those with hold I " data " ...
http://rosettacode.org/wiki/Reverse_words_in_a_string
Reverse words in a string
Task Reverse the order of all tokens in each of a number of strings and display the result;   the order of characters within a token should not be modified. Example Hey you, Bub!   would be shown reversed as:   Bub! you, Hey Tokens are any non-space characters separated by spaces (formally, white-space);   t...
#zkl
zkl
text:=Data(0,String, #<<< "---------- Ice and Fire ------------   fire, in end will world the say Some ice. in say Some desire of tasted I've what From fire. favor who those with hold I   ... elided paragraph last ...   Frost Robert -----------------------"); #<<<   text.pump(11,Data,fcn(s){ // process stripped lines ...
http://rosettacode.org/wiki/Rot-13
Rot-13
Task Implement a   rot-13   function   (or procedure, class, subroutine, or other "callable" object as appropriate to your programming environment). Optionally wrap this function in a utility program   (like tr,   which acts like a common UNIX utility, performing a line-by-line rot-13 encoding of every line of inpu...
#Zoea
Zoea
  program: rot13 case: 1 input: abc output: nop case: 2 input: nop output: abc case: 3 input: 'ABC' output: 'NOP' case: 4 input: 'NOP' output: 'ABC'  
http://rosettacode.org/wiki/Roman_numerals/Encode
Roman numerals/Encode
Task Create a function taking a positive integer as its parameter and returning a string containing the Roman numeral representation of that integer. Modern Roman numerals are written by expressing each digit separately, starting with the left most digit and skipping any digit with a value of zero. In Roman numeral...
#zkl
zkl
var [const] romans = L( L("M", 1000), L("CM", 900), L("D", 500), L("CD", 400), L("C", 100), L("XC", 90), L("L", 50), L("XL", 40), L("X", 10), L("IX", 9), L("V", 5), L("IV", 4), L("I", 1)); fcn toRoman(i){ // convert int to a roman number reg text = ""; foreach R,N in (romans){ text += ...
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#Nemerle
Nemerle
using System; using System.Console;   module StrRep { Repeat(this s : string, n : int) : string { String('x', n).Replace("x", s) }   Main() : void { WriteLine("ha".Repeat(5)); WriteLine("*".Repeat(5)); WriteLine(String('*', 5)); // repeating single char   } }
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#NetRexx
NetRexx
/* NetRexx */   ha5 = 'ha'.copies(5)  
http://rosettacode.org/wiki/Remove_duplicate_elements
Remove duplicate elements
Sorting Algorithm This is a sorting algorithm.   It may be applied to a set of data in order to sort it.     For comparing various sorts, see compare sorts.   For other sorting algorithms,   see sorting algorithms,   or: O(n logn) sorts Heap sort | Merge sort | Patience sort | Quick sort O(n log2n) sorts Shell Sort ...
#Logo
Logo
show remdup [1 2 3 a b c 2 3 4 b c d]  ; [1 a 2 3 4 b c d]
http://rosettacode.org/wiki/Reduced_row_echelon_form
Reduced row echelon form
Reduced row echelon form You are encouraged to solve this task according to the task description, using any language you may know. Task Show how to compute the reduced row echelon form (a.k.a. row canonical form) of a matrix. The matrix can be stored in any datatype that is convenient (for most languages, this wil...
#Rust
Rust
  fn main() { let mut matrix_to_reduce: Vec<Vec<f64>> = vec![vec![1.0, 2.0 , -1.0, -4.0], vec![2.0, 3.0, -1.0, -11.0], vec![-2.0, 0.0, -3.0, 22.0]]; let mut r_mat_to_red = &mut matrix_to_reduce; let rr_mat_to_re...
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#Oforth
Oforth
import: math   : testReal E println Pi println 9 sqrt println 2 ln println 2 exp println -3.4 abs println 3.4 exp println   2.4 floor println 3.9 floor println 5.5 floor println -2.4 floor println -3.9 floor println -5.5 floor println   2.4 ceil println 3.9 ceil println 5.5 ...
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#ooRexx
ooRexx
/* Rexx */   -- MathLoadFuncs & MathDropFuncs are no longer needed and are effectively NOPs -- but MathLoadFuncs does return its copyright statement when given a string argument RxMathCopyright = MathLoadFuncs('') say RxMathCopyright   numeric digits 16   x = 2.5 y = 3 pad = 40 digs = digits() say say 'Working with pre...
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#PureBasic
PureBasic
Number.b = ReadByte(#File) Length.i = ReadData(#File, *MemoryBuffer, LengthToRead) Number.c = ReadCharacter(#File) Number.d = ReadDouble(#File) Number.f = ReadFloat(#File) Number.i = ReadInteger(#File) Number.l = ReadLong(#File) Number.q = ReadQuad(#File) Text$ = ReadString(#File [, Flags]) Number.w = ReadWord(#File...
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#Python
Python
open(filename).read()
http://rosettacode.org/wiki/Reverse_a_string
Reverse a string
Task Take a string and reverse it. For example, "asdf" becomes "fdsa". Extra credit Preserve Unicode combining characters. For example, "as⃝df̅" becomes "f̅ds⃝a", not "̅fd⃝sa". Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting ...
#Explore
Explore
    ## இந்த நிரல் தரப்படும் சரம் ஒன்றைத் தலைகீழாகத் திருப்பி அச்சிடும் ## உதாரணமாக "abc" என்ற சரம் தரப்பட்டால் அதனைத் திருப்பி "cba" என அச்சிடும் ## "எழில்" மொழியின்மூலம் இரண்டு வகைகளில் இதனைச் செய்யலாம். இரண்டு உதாரணங்களும் இங்கே தரப்பட்டுள்ளன   நிரல்பாகம் திருப்புக (சரம்1)   ## முதல் வகை   சரம்2 = ""   @(...
http://rosettacode.org/wiki/Rot-13
Rot-13
Task Implement a   rot-13   function   (or procedure, class, subroutine, or other "callable" object as appropriate to your programming environment). Optionally wrap this function in a utility program   (like tr,   which acts like a common UNIX utility, performing a line-by-line rot-13 encoding of every line of inpu...
#Zoea_Visual
Zoea Visual
10 CLS 20 INPUT "Enter a string: ", s$ 30 LET a$ = "": REM a$ is the encoded string 40 FOR l = 1 TO LEN(s$) 50 LET i$ = s$(l): REM i$ is the letter being worked on 60 IF i$ < "A" OR i$ > "Z" THEN GO TO 100 70 LET c$ = CHR$(CODE(i$) + 13): REM c$ is the encoded letter 80 IF c$ > "Z" THEN LET c$ = CHR$(CODE(c$) - 26) ...
http://rosettacode.org/wiki/Roman_numerals/Encode
Roman numerals/Encode
Task Create a function taking a positive integer as its parameter and returning a string containing the Roman numeral representation of that integer. Modern Roman numerals are written by expressing each digit separately, starting with the left most digit and skipping any digit with a value of zero. In Roman numeral...
#Zoea
Zoea
  program: decimal_roman input: 12 output: 'XII'  
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#NewLISP
NewLISP
(dup "ha" 5)
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#Nim
Nim
import strutils   # Repeat a char. echo repeat('a', 5) # -> "aaaaa".   # Repeat a string. echo repeat("ha", 5) # -> "hahahahaha".
http://rosettacode.org/wiki/Remove_duplicate_elements
Remove duplicate elements
Sorting Algorithm This is a sorting algorithm.   It may be applied to a set of data in order to sort it.     For comparing various sorts, see compare sorts.   For other sorting algorithms,   see sorting algorithms,   or: O(n logn) sorts Heap sort | Merge sort | Patience sort | Quick sort O(n log2n) sorts Shell Sort ...
#Lua
Lua
items = {1,2,3,4,1,2,3,4,"bird","cat","dog","dog","bird"} flags = {} io.write('Unique items are:') for i=1,#items do if not flags[items[i]] then io.write(' ' .. items[i]) flags[items[i]] = true end end io.write('\n')
http://rosettacode.org/wiki/Reduced_row_echelon_form
Reduced row echelon form
Reduced row echelon form You are encouraged to solve this task according to the task description, using any language you may know. Task Show how to compute the reduced row echelon form (a.k.a. row canonical form) of a matrix. The matrix can be stored in any datatype that is convenient (for most languages, this wil...
#Sage
Sage
sage: m = matrix(ZZ, [[1,2,-1,-4],[2,3,-1,-11],[-2,0,-3,22]]) sage: m.rref() ...
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#Oz
Oz
{ForAll [ {Exp 1.} %% 2.7183 Euler's number: not predefined 4. * {Atan2 1. 1.} %% 3.1416 pi: not predefined {Sqrt 81.} %% 9.0 square root; expects a float {Log 2.7183} %% 1.0 natural logarithm {Abs ~1} %% 1 absolute value; expects a float or an integer ...
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#PARI.2FGP
PARI/GP
[exp(1), Pi, sqrt(2), log(2), abs(2), floor(2), ceil(2), 2^3]
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#Quackery
Quackery
$ "myfile.txt" sharefile
http://rosettacode.org/wiki/Read_entire_file
Read entire file
Task Load the entire contents of some text file as a single string variable. If applicable, discuss: encoding selection, the possibility of memory-mapping. Of course, in practice one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case...
#Q
Q
q)file:read0`:file.txt "First line of file" "Second line of file" ""
http://rosettacode.org/wiki/Reverse_a_string
Reverse a string
Task Take a string and reverse it. For example, "asdf" becomes "fdsa". Extra credit Preserve Unicode combining characters. For example, "as⃝df̅" becomes "f̅ds⃝a", not "̅fd⃝sa". Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting ...
#Ezhil
Ezhil
    ## இந்த நிரல் தரப்படும் சரம் ஒன்றைத் தலைகீழாகத் திருப்பி அச்சிடும் ## உதாரணமாக "abc" என்ற சரம் தரப்பட்டால் அதனைத் திருப்பி "cba" என அச்சிடும் ## "எழில்" மொழியின்மூலம் இரண்டு வகைகளில் இதனைச் செய்யலாம். இரண்டு உதாரணங்களும் இங்கே தரப்பட்டுள்ளன   நிரல்பாகம் திருப்புக (சரம்1)   ## முதல் வகை   சரம்2 = ""   @(...
http://rosettacode.org/wiki/Rot-13
Rot-13
Task Implement a   rot-13   function   (or procedure, class, subroutine, or other "callable" object as appropriate to your programming environment). Optionally wrap this function in a utility program   (like tr,   which acts like a common UNIX utility, performing a line-by-line rot-13 encoding of every line of inpu...
#ZX_Spectrum_Basic
ZX Spectrum Basic
10 CLS 20 INPUT "Enter a string: ", s$ 30 LET a$ = "": REM a$ is the encoded string 40 FOR l = 1 TO LEN(s$) 50 LET i$ = s$(l): REM i$ is the letter being worked on 60 IF i$ < "A" OR i$ > "Z" THEN GO TO 100 70 LET c$ = CHR$(CODE(i$) + 13): REM c$ is the encoded letter 80 IF c$ > "Z" THEN LET c$ = CHR$(CODE(c$) - 26) ...
http://rosettacode.org/wiki/Roman_numerals/Encode
Roman numerals/Encode
Task Create a function taking a positive integer as its parameter and returning a string containing the Roman numeral representation of that integer. Modern Roman numerals are written by expressing each digit separately, starting with the left most digit and skipping any digit with a value of zero. In Roman numeral...
#Zoea_Visual
Zoea Visual
function printroman () { local -a conv local number=$1 div rom num out conv=(I 1 IV 4 V 5 IX 9 X 10 XL 40 L 50 XC 90 C 100 CD 400 D 500 CM 900 M 1000) for num rom in ${(Oa)conv}; do (( div = number / num, number = number % num )) while (( div-- > 0 )); do out+=$rom done done echo $out }
http://rosettacode.org/wiki/Repeat_a_string
Repeat a string
Take a string and repeat it some number of times. Example: repeat("ha", 5)   =>   "hahahahaha" If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). Other tasks re...
#Objeck
Objeck
bundle Default { class Repeat { function : Main(args : String[]) ~ Nil { Repeat("ha", 5)->PrintLine(); }   function : Repeat(string : String, max : Int) ~ String { repeat : String := String->New(); for(i := 0; i < max; i += 1;) { repeat->Append(string); };   return re...
http://rosettacode.org/wiki/Remove_duplicate_elements
Remove duplicate elements
Sorting Algorithm This is a sorting algorithm.   It may be applied to a set of data in order to sort it.     For comparing various sorts, see compare sorts.   For other sorting algorithms,   see sorting algorithms,   or: O(n logn) sorts Heap sort | Merge sort | Patience sort | Quick sort O(n log2n) sorts Shell Sort ...
#Maple
Maple
> L := [ 1, 2, 1, 2, 3, 3, 2, 1, "a", "b", "b", "a", "c", "b" ]; L := [1, 2, 1, 2, 3, 3, 2, 1, "a", "b", "b", "a", "c", "b"]   > [op]({op}(L)); [1, 2, 3, "a", "b", "c"]
http://rosettacode.org/wiki/Reduced_row_echelon_form
Reduced row echelon form
Reduced row echelon form You are encouraged to solve this task according to the task description, using any language you may know. Task Show how to compute the reduced row echelon form (a.k.a. row canonical form) of a matrix. The matrix can be stored in any datatype that is convenient (for most languages, this wil...
#Scheme
Scheme
(define (reduced-row-echelon-form matrix) (define (clean-down matrix from-row column) (cons (car matrix) (if (zero? from-row) (map (lambda (row) (map - row (map (lambda (element) (/ (*...
http://rosettacode.org/wiki/Real_constants_and_functions
Real constants and functions
Task Show how to use the following math constants and functions in your language   (if not available, note it):   e   (base of the natural logarithm)   π {\displaystyle \pi }   square root   logarithm   (any base allowed)   exponential   (ex )   absolute value   (a.k.a. "magnitude")   floor   (largest ...
#Pascal
Pascal
{ Euler’s constant } exp(1) { principal square root of `x` } sqrt(x) { natural logarithm } ln(x) { exponential } exp(x) { absolute value } abs(x)