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/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Frink
Frink
print[read["-"]]
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Go
Go
package main   import ( "bufio" "io" "os" )   func main() { r := bufio.NewReader(os.Stdin) w := bufio.NewWriter(os.Stdout) for { b, err := r.ReadByte() if err == io.EOF { return } w.WriteByte(b) w.Flush() } }
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Groovy
Groovy
class StdInToStdOut { static void main(args) { try (def reader = System.in.newReader()) { def line while ((line = reader.readLine()) != null) { println line } } } }
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#Rust
Rust
extern crate rand;   use rand::Rng;   fn random_cell<R: Rng>(rng: &mut R) -> u32 { // Anything between 0 and 10_000 (exclusive) has 4 digits or fewer. Using `gen_range::<u32>` // is faster for smaller RNGs. Because the parameters are constant, the compiler can do all // the range construction at compile ti...
http://rosettacode.org/wiki/CSV_to_HTML_translation
CSV to HTML translation
Consider a simplified CSV format where all rows are separated by a newline and all columns are separated by commas. No commas are allowed as field data, but the data may contain other characters and character sequences that would normally be   escaped   when converted to HTML Task Create a function that takes a st...
#zkl
zkl
csvData:=Data(0,Int,"Character,Speech\n" "The multitude,The messiah! Show us the messiah!\n" "Brians mother,<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>\n" "The multitude,Who are you\n" "Brians mother,I'm his mother; that's who!\n" "The multitude,Behold his mother! Beh...
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Haskell
Haskell
main = interact id
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Java
Java
  import java.util.Scanner;   public class CopyStdinToStdout {   public static void main(String[] args) { try (Scanner scanner = new Scanner(System.in);) { String s; while ( (s = scanner.nextLine()).compareTo("") != 0 ) { System.out.println(s); } }...
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#JavaScript
JavaScript
process.stdin.resume(); process.stdin.pipe(process.stdout);
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#Scala
Scala
object TableGenerator extends App { val data = List(List("X", "Y", "Z"), List(11, 12, 13), List(12, 22, 23), List(13, 32, 33))   def generateTable(data: List[List[Any]]) = { <table> {data.zipWithIndex.map { case (row, rownum) => (if (rownum == 0) Nil else rownum) +: row}. map(row => <tr> {row....
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#jq
jq
jq -Rr .
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Julia
Julia
while !eof(stdin) write(stdout, read(stdin, UInt8)) end
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Kotlin
Kotlin
fun main() { var c: Int do { c = System.`in`.read() System.out.write(c) } while (c >= 0) }
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Latitude
Latitude
while { $stdin eof? not. } do { $stdout putln: $stdin readln. }.
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Lua
Lua
lua -e 'for x in io.lines() do print(x) end'
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#Scheme
Scheme
(define table #( #("" "X" "Y" "Z") #(1 1 2 3) #(2 4 5 6) #(3 7 8 9)))   (display "<table>") (do ((r 0 (+ r 1))) ((eq? r (vector-length table))) (display "<tr>") (do ((c 0 (+ c 1))) ((eq? c (vector-length (vector-ref table r)))) ...
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Mercury
Mercury
    :- module stdin_to_stdout. :- interface.   :- import_module io.   :- pred main(io::di, io::uo) is det.   %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------%   :- implementation.   :- import_module char. :- im...
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Nim
Nim
stdout.write readAll(stdin)
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#OCaml
OCaml
try while true do output_char stdout (input_char stdin) done with End_of_file -> ()
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Ol
Ol
  (bytestream->port (port->bytestream stdin) stdout)  
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#Seed7
Seed7
$ include "seed7_05.s7i";   const proc: main is func local var integer: line is 0; var integer: column is 0; begin writeln("<table style=\"text-align:center; border: 1px solid\">"); writeln("<tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>"); for line range 1 to 3 do write("<tr><th>" <& li...
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Pascal
Pascal
program writeInput(input, output); var buffer: char; begin while not EOF() do begin read(buffer); // shorthand for read(input, buffer) write(buffer); // shorthand for write(output, buffer) end; end.
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Perl
Perl
  perl -pe ''  
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Phix
Phix
without js while true do integer ch = wait_key() if ch=#1B then exit end if puts(1,ch) end while
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#PicoLisp
PicoLisp
(in NIL (echo))
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#Sidef
Sidef
class HTML { method _attr(Hash h) { h.keys.sort.map {|k| %Q' #{k}="#{h{k}}"' }.join('') }   method _tag(Hash h, name, value) { "<#{name}" + self._attr(h) + '>' + value + "</#{name}>" }   method table(Hash h, *data) { self._tag(h, 'table', data.join('')) } method table(*data) ...
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Prolog
Prolog
  %File: stdin_to_stdout.pl :- initialization(main).   main :- repeat, get_char(X), put_char(X), X == end_of_file, fail.  
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Python
Python
python -c 'import sys; sys.stdout.write(sys.stdin.read())'
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#R
R
Rscript -e 'cat(readLines(file("stdin")))'
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Racket
Racket
#lang racket   (let loop () (match (read-char) [(? eof-object?) (void)] [c (display c) (loop)]))
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Raku
Raku
raku -pe'.lines'
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#Snobol4
Snobol4
* HTML Table output = "<table>" output = " <tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>" i = 1 o1 output = "<tr><td>" i "</td>" j = 1 o2 output = "<td>" i j "</td>" j = lt(j,3) j + 1 :s(o2) output = "</tr>" i = lt(i,3) i + 1 :s(o1) output = "</table>" end    
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#REXX
REXX
/*REXX pgm copies data from STDIN──►STDOUT (default input stream──►default output stream*/   do while chars()\==0 /*repeat loop until no more characters.*/ call charin , x /*read a char from the input stream. */ call charout , x ...
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Ring
Ring
  ? "give input: " give str ? "output: " + str  
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Rust
Rust
use std::io;   fn main() { io::copy(&mut io::stdin().lock(), &mut io::stdout().lock()); }
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Scala
Scala
object CopyStdinToStdout extends App { io.Source.fromInputStream(System.in).getLines().foreach(println) }
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#Standard_ML
Standard ML
(* * val mkHtmlTable : ('a list * 'b list) -> ('a -> string * 'b -> string) * -> (('a * 'b) -> string) -> string * The int list is list of colums, the function returns the values * at a given colum and row. * returns the HTML code of the generated table. *) fun mkHtmlTable (columns, rows) (rowToStr, colToStr)...
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Scheme
Scheme
  (do ((c (read-char) (read-char))) ((eof-object? c) 'done) (display c))  
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#sed
sed
  sed -e ''  
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Seed7
Seed7
$ include "seed7_05.s7i"; include "fileutil.s7i";   const proc: main is func begin copyFile(IN, OUT); end func;
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Smalltalk
Smalltalk
"using Stream class's bulk copy method:" Stdin copyToEndInto:Stdout.   "line wise" [Stdin atEnd] whileFalse:[ Stdout nextPutLine:(Stdin nextLine) ].   "character wise" [Stdin atEnd] whileFalse:[ Stdout nextPut:(Stdin next) ].   "no EOF test, but handle EOF Exception" [ [ Stdout nextPut:(Stdin next) ] loop. ] on: St...
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#Stata
Stata
program mat2html local nr = rowsof(`1') local nc = colsof(`1') local rn `: rownames `1'' local cn `: colnames `1'' tempname f qui file open `f' using `2', write text replace file write `f' "<!doctype html>" _n file write `f' "<html>" _n file write `f' "<head>" _n file write `f' `"<meta charset="UTF-8">"' _n file write ...
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Standard_ML
Standard ML
fun copyLoop () = case TextIO.input TextIO.stdIn of "" => () | tx => copyLoop (TextIO.output (TextIO.stdOut, tx))   val () = copyLoop ()
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Symsyn
Symsyn
  Loop [] [] go Loop  
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Tcl
Tcl
package require Tcl 8.5   chan copy stdin stdout # fcopy stdin stdout for older versions
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#VBScript
VBScript
  do s=wscript.stdin.readline wscript.stdout.writeline s loop until asc(left(s,1))=26  
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#Wren
Wren
import "io" for Stdin, Stdout   Stdin.isRaw = true // prevents echoing to the terminal while (true) { var byte = Stdin.readByte() // read a byte from stdin if (byte == 13) break // break when enter key pressed System.write(String.fromByte(byte)) // write the byte (in string form) to st...
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#Tcl
Tcl
# Make ourselves a very simple templating lib; just two commands proc TAG {name args} { set body [lindex $args end] set result "<$name" foreach {t v} [lrange $args 0 end-1] { append result " $t=\"" $v "\"" } append result ">" [string trim [uplevel 1 [list subst $body]]] "</$name>" } proc FOREACH {v...
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#XPL0
XPL0
int C; loop [C:= ChIn(1); if C = $1A \EOF\ then quit; ChOut(0, C); ]
http://rosettacode.org/wiki/Copy_stdin_to_stdout
Copy stdin to stdout
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
#zkl
zkl
zkl --eval "File.stdout.write(File.stdin.read())"
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#TUSCRIPT
TUSCRIPT
  $$ MODE TUSCRIPT tablefile="table.html" ERROR/STOP CREATE (tablefile,FDF-o,-std-) ACCESS d: WRITE/ERASE/RECORDS/utf8 $tablefile s,tablecontent tablecontent=* WRITE d "<!DOCTYPE html system>" WRITE d "<html><head><title>create html table</title></head>" WRITE d "<body><table><thead align='right'>" WRITE d "<tr><th>&nb...
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#UNIX_Shell
UNIX Shell
function emit_table { nameref d=$1 typeset -i idx=0 echo "<table>" emit_row th "" "${d[idx++][@]}" for (( ; idx<${#d[@]}; idx++ )); do emit_row td $idx "${d[idx][@]}" done echo "</table>" }   function emit_row { typeset tag=$1; shift typeset row="<tr>" for elem; do ...
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#Ursa
Ursa
decl ursa.util.random random   out "<table>" endl console   # generate header out "<tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>" endl console   # generate five rows decl int i for (set i 1) (< i 6) (inc i) out "<tr><td style=\"font-weight: bold;\">" i "</td>" console out "<td>" (int (+ 1000 (random....
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#VBA
VBA
  Public Sub BuildHTMLTable() 'simple HTML table, represented as a string matrix "cells" Const nRows = 6 Const nCols = 4 Dim cells(1 To nRows, 1 To nCols) As String Dim HTML As String 'the HTML table Dim temp As String Dim attr As String   ' fill table ' first row with titles cells(1, 1) = "" cells(1, 2) = "X" cells(1,...
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#VBScript
VBScript
  Set objFSO = CreateObject("Scripting.FileSystemObject")   'Open the input csv file for reading. The file is in the same folder as the script. Set objInFile = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_ "\in.csv",1)   'Create the output html file. Set objOutHTML = objFSO.OpenTextFile(obj...
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#Visual_Basic_.NET
Visual Basic .NET
Module Program Sub Main() Const ROWS = 3 Const COLS = 3   Dim rand As New Random(0) Dim getNumber = Function() rand.Next(10000)   Dim result = <table cellspacing="4" style="text-align:right; border:1px solid;"> <tr> <th></th> <th>X</th> <th>Y</th> ...
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#Wren
Wren
import "random" for Random import "/fmt" for Fmt   var r = Random.new() var sb = "" var i = " " // indent sb = sb + "<html>\n<head>\n" sb = sb + "<style>\n" sb = sb + "table, th, td { border: 1px solid black; }\n" sb = sb + "th, td { text-align: right; }\n" sb = sb + "</style>\n</head>\n<body>\n" sb = sb + "<table ...
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#XSLT
XSLT
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" version="4.01" indent="yes"/>   <!-- Most XSLT processors have some way to supply a different value for this parameter --> <xsl:param name="column-count" select="3...
http://rosettacode.org/wiki/Create_an_HTML_table
Create an HTML table
Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled "X", "Y", and "Z". An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. The...
#zkl
zkl
table:=0'|<table style="text-align:center; border: 1px solid">| "<th></th><th>X</th><th>Y</th><th>Z</th><tr>"; table=Sink(table); foreach n in ([1..3]){ table.write("\n <tr><th>",n,"</th>"); foreach n in (3){ table.write("<td>",(0).random(10000),"</td>"); } table.write("</tr>"); } table.write("\n</t...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#11l
11l
F r2cf(=n1, =n2) [Int] r L n2 != 0 (n1, V t1_n2) = (n2, divmod(n1, n2)) n2 = t1_n2[1] r [+]= t1_n2[0] R r   print(r2cf(1, 2)) print(r2cf(3, 1)) print(r2cf(23, 8)) print(r2cf(13, 11)) print(r2cf(22, 7)) print(r2cf(14142, 10000)) print(r2cf(141421, 100000)) print(r2cf(1414214, 1000000)) print(r...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#ALGOL_68
ALGOL 68
BEGIN # construct continued fraction representations of rational numbers # # Translated from the C sample # # Uses code from the Arithmetic/Rational task #   # Code from the Arithmetic/Rational task # # ================...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#11l
11l
T Rational Int numerator Int denominator   F (numerator, denominator) .numerator = numerator .denominator = denominator   F String() I .denominator == 1 R String(.numerator) E R .numerator‘//’(.denominator)   F rationalize(x, tol = 1e-12) V xx = x V flagNeg = ...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#C
C
  #include<stdio.h>   typedef struct{ int num,den; }fraction;   fraction examples[] = {{1,2}, {3,1}, {23,8}, {13,11}, {22,7}, {-151,77}}; fraction sqrt2[] = {{14142,10000}, {141421,100000}, {1414214,1000000}, {14142136,10000000}}; fraction pi[] = {{31,10}, {314,100}, {3142,1000}, {31428,10000}, {314285,100000}, {314...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#Ada
Ada
generic type Real is digits <>; procedure Real_To_Rational(R: Real; Bound: Positive; Nominator: out Integer; Denominator: out Positive);
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#AppleScript
AppleScript
--------- RATIONAL APPROXIMATION TO DECIMAL NUMBER -------   -- approxRatio :: Real -> Real -> Ratio on approxRatio(epsilon, n) if {real, integer} contains (class of epsilon) and 0 < epsilon then -- Given set e to epsilon else -- Default set e to 1 / 10000 end if   script...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#C.23
C#
using System; using System.Collections.Generic;   class Program { static IEnumerable<int> r2cf(int n1, int n2) { while (Math.Abs(n2) > 0) { int t1 = n1 / n2; int t2 = n2; n2 = n1 - t1 * n2; n1 = t2; yield return t1; } }   ...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#AutoHotkey
AutoHotkey
Array := [] inputbox, string, Enter Number stringsplit, string, string, . if ( string1 = 0 ) string1 = loop, parse, string, . if A_index = 2 loop, parse, A_loopfield Array[A_index] := A_loopfield, ...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#C.2B.2B
C++
#include <iostream> /* Interface for all Continued Fractions Nigel Galloway, February 9th., 2013. */ class ContinuedFraction { public: virtual const int nextTerm(){}; virtual const bool moreTerms(){}; }; /* Create a continued fraction from a rational number Nigel Galloway, February 9th., 2013. */ class r2cf : ...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#Bracmat
Bracmat
( ( exact = integerPart decimalPart z . @(!arg:?integerPart "." ?decimalPart) &  !integerPart + ( @( !decimalPart  : (? ((%@:~0) ?:?decimalPart)) [?z ) & !decimalPart*10^(-1*!z) | 0 ) | !arg ) & ( approximati...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#C
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <stdint.h>   /* f : number to convert. * num, denom: returned parts of the rational. * md: max denominator value. Note that machine floating point number * has a finite resolution (10e-16 ish for 64 bit double), so specifying * a "best match...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#Clojure
Clojure
(defn r2cf [n d] (if-not (= d 0) (cons (quot n d) (lazy-seq (r2cf d (rem n d))))))   ; Example usage (def demo '((1 2) (3 1) (23 8) (13 11) (22 7) (-151 77) (14142 10000) (141421 100000) (1414214 1000000) (1414...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#C.23
C#
using System; using System.Text;   namespace RosettaDecimalToFraction { public class Fraction { public Int64 Numerator; public Int64 Denominator; public Fraction(double f, Int64 MaximumDenominator = 4096) { /* Translated from the C version. */ /* a: conti...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#Common_Lisp
Common Lisp
(defun r2cf (n1 n2) (lambda () (unless (zerop n2) (multiple-value-bind (t1 r) (floor n1 n2) (setf n1 n2 n2 r) t1))))   ;; Example usage   (defun demo-generator (numbers) (let* ((n1 (car numbers)) (n2 (cadr numbers)) (gen (r2cf n1 n2))) (format t "~S  ; ~S~%"...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#Clojure
Clojure
user=> (rationalize 0.1) 1/10 user=> (rationalize 0.9054054) 4527027/5000000 user=> (rationalize 0.518518) 259259/500000 user=> (rationalize Math/PI) 3141592653589793/1000000000000000
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#Common_Lisp
Common Lisp
> (rational 0.9054054) 7595091/8388608 > (rationalize 0.9054054) 67/74 > (= (rational 0.9054054) 0.9054054) T > (= (rationalize 0.9054054) 0.9054054) NIL > (rational .518518) 1087411/2097152 > (rationalize .518518) 33279/64181 > (rational .5185185) 8699297/16777216 > (rationalize .5185185) 14/27 > (rational .75) 3/4 > ...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#D
D
import std.concurrency; import std.stdio;   struct Pair { int first, second; }   auto r2cf(Pair frac) { return new Generator!int({ auto num = frac.first; auto den = frac.second; while (den != 0) { auto div = num / den; auto rem = num % den; num = den; ...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#D
D
import std.stdio, std.math, std.string, std.typecons;   alias Fraction = Tuple!(int,"nominator", uint,"denominator");   Fraction real2Rational(in real r, in uint bound) /*pure*/ nothrow { if (r == 0.0) { return Fraction(0, 1); } else if (r < 0.0) { auto result = real2Rational(-r, bound); ...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#EDSAC_order_code
EDSAC order code
  [Continued fractions from rationals. EDSAC program, Initial Orders 2.]   [Memory usage: 56..109 Print subroutine, modified from the EDSAC library 110..146 Division subroutine for long positive integers 148..196 Continued fraction subroutine, as specified by Rosetta Code 200..260 Main routine 262.. ...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#Delphi
Delphi
  program Convert_decimal_number_to_rational;   {$APPTYPE CONSOLE}   uses Velthuis.BigRationals, Velthuis.BigDecimals;   const Tests: TArray<string> = ['0.9054054', '0.518518', '0.75'];   var Rational: BigRational; Decimal: BigDecimal;   begin for var test in Tests do begin Decimal := test; Ration...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#F.23
F#
let rec r2cf n d = if d = LanguagePrimitives.GenericZero then [] else let q = n / d in q :: (r2cf d (n - q * d))   [<EntryPoint>] let main argv = printfn "%A" (r2cf 1 2) printfn "%A" (r2cf 3 1) printfn "%A" (r2cf 23 8) printfn "%A" (r2cf 13 11) printfn "%A" (r2cf 22 7) printfn "%A" (r2c...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#EchoLisp
EchoLisp
  (exact->inexact 67/74) → 0.9054054054054054 (inexact->exact 0.9054054054054054) → 67/74   (rationalize 0.7978723404255319) → 75/94   ;; finding rational approximations of PI (for ((ε (in-range -1 -15 -1))) (writeln ( format "precision:10^%d %t PI = %d" ε (rationalize PI (expt 10 e)))))   "precision...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#Factor
Factor
USING: formatting kernel lists lists.lazy math math.parser qw sequences ; IN: rosetta-code.cf-arithmetic   : r2cf ( x -- lazy ) [ >fraction [ /mod ] keep swap [ ] [ / ] if-zero nip ] lfrom-by [ integer? ] luntil [ >fraction /i ] lmap-lazy ;   : main ( -- ) qw{ 1/2 3 23/8 13/1...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#Forth
Forth
: r2cf ( num1 den1 -- num2 den2 ) swap over >r s>d r> sm/rem . ;   : .r2cf ( num den -- ) cr 2dup swap . ." / " . ." : " begin r2cf dup 0<> while repeat 2drop ;   : r2cf-demo 1 2 .r2cf 3 1 .r2cf 23 8 .r2cf 13 11 .r2cf 22 7 .r2cf -151 77 .r...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#Factor
Factor
USING: kernel math.floating-point prettyprint ;   0.9054054 0.518518 0.75 [ double>ratio . ] tri@
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#Fermat
Fermat
>3.14 157 / 50; or 3.1400000000000000000000000000000000000000 >10.00000 10 >77.7777 777777 / 10000; or 77.7777000000000000000000000000000000000000 >-5.5 -11 / 2; or -5.5000000000000000000000000000000000000000
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#FreeBASIC
FreeBASIC
  'with some other constants data 1,2, 21,7, 21,-7, 7,21, -7,21 data 23,8, 13,11, 22,7, 3035,5258, -151,-77 data -151,77, 77,151, 77,-151, -832040,1346269 data 63018038201,44560482149, 14142,10000 data 31,10, 314,100, 3142,1000, 31428,10000, 314285,100000 data 3142857,1000000, 31428571,10000000, 314285714,100000000 dat...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#Forth
Forth
  \ Brute force search, optimized to search only within integer bounds surrounding target \ Forth 200x compliant   : RealToRational ( float_target int_denominator_limit -- numerator denominator ) {: f: thereal denlimit | realscale numtor denom neg? f: besterror f: temperror :} 0 to numtor 0 to denom ...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#Go
Go
package cf   import ( "fmt" "strings" )   // ContinuedFraction is a regular continued fraction. type ContinuedFraction func() NextFn   // NextFn is a function/closure that can return // a posibly infinite sequence of values. type NextFn func() (term int64, ok bool)   // String implements fmt.Stringer. // It formats a...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#Fortran
Fortran
MODULE PQ !Plays with some integer arithmetic. INTEGER MSG !Output unit number. CONTAINS !One good routine. INTEGER FUNCTION GCD(I,J) !Greatest common divisor. INTEGER I,J !Of these two integers. INTEGER N,M,R !Workers. N = MAX(I,J) !Since I don't want to damage ...
http://rosettacode.org/wiki/Copy_a_string
Copy a string
This task is about copying a string. Task Where it is relevant, distinguish between copying the contents of a string versus making an additional reference to an existing string. Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting W...
#11l
11l
V src = ‘hello’ V dst = copy(src)
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#Haskell
Haskell
import Data.Ratio ((%))   real2cf :: (RealFrac a, Integral b) => a -> [b] real2cf x = let (i, f) = properFraction x in i : if f == 0 then [] else real2cf (1 / f)   main :: IO () main = mapM_ print [ real2cf (13 % 11) , take 20 $ real2cf (sqrt 2) ]
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#FreeBASIC
FreeBASIC
'' Written in FreeBASIC '' (no error checking, limited to 64-bit signed math) type number as longint #define str2num vallng #define pow10(n) clngint(10 ^ (n))   function gcd(a as number, b as number) as number if a = 0 then return b return gcd(b mod a, a) end function     function parserational(n as const strin...
http://rosettacode.org/wiki/Copy_a_string
Copy a string
This task is about copying a string. Task Where it is relevant, distinguish between copying the contents of a string versus making an additional reference to an existing string. Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting W...
#360_Assembly
360 Assembly
* Duplicate a string MVC A,=CL64'Hello' a='Hello' MVC B,A b=a memory copy MVC A,=CL64'Goodbye' a='Goodbye' XPRNT A,L'A print a XPRNT B,L'B print b ... * Make reference to a string a str...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#J
J
cf=: _1 1 ,@}. (, <.)@%@-/ ::]^:a:@(, <.)@(%&x:/)
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#F.C5.8Drmul.C3.A6
Fōrmulæ
package main   import ( "fmt" "math/big" )   func main() { for _, d := range []string{"0.9054054", "0.518518", "0.75"} { if r, ok := new(big.Rat).SetString(d); ok { fmt.Println(d, "=", r) } else { fmt.Println(d, "invalid decimal number") } } }
http://rosettacode.org/wiki/Copy_a_string
Copy a string
This task is about copying a string. Task Where it is relevant, distinguish between copying the contents of a string versus making an additional reference to an existing string. Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting W...
#68000_Assembly
68000 Assembly
myString: DC.B "HELLO WORLD",0 EVEN   LEA myString,A3
http://rosettacode.org/wiki/Copy_a_string
Copy a string
This task is about copying a string. Task Where it is relevant, distinguish between copying the contents of a string versus making an additional reference to an existing string. Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting W...
#8086_Assembly
8086 Assembly
.model small .stack 1024   .data   myString byte "Hello World!",0 ; a null-terminated string   myStruct word 0   .code   mov ax,@data mov ds,ax ;load data segment into DS   mov bx,offset myString ;get the pointer to myString   mov word ptr [ds:myStruct],bx   mov ax,4C00h int 21h ;quit program and re...
http://rosettacode.org/wiki/Continued_fraction/Arithmetic/Construct_from_rational_number
Continued fraction/Arithmetic/Construct from rational number
Continued fraction arithmetic The purpose of this task is to write a function r 2 c f ( i n t {\displaystyle {\mathit {r2cf}}(\mathrm {int} } N 1 , i n t {\displaystyle N_{1},\mathrm {int} } N 2 ) {\displaystyle N_{2})} , or r 2 c f ( F r a c t i o n {\displaystyle {\m...
#Java
Java
import java.util.Iterator; import java.util.List; import java.util.Map;   public class ConstructFromRationalNumber { private static class R2cf implements Iterator<Integer> { private int num; private int den;   R2cf(int num, int den) { this.num = num; this.den = den; ...
http://rosettacode.org/wiki/Convert_decimal_number_to_rational
Convert decimal number to rational
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. The task is to write a program to transform a decimal number into a fraction in lowest terms. It is not always possible to do this...
#Go
Go
package main   import ( "fmt" "math/big" )   func main() { for _, d := range []string{"0.9054054", "0.518518", "0.75"} { if r, ok := new(big.Rat).SetString(d); ok { fmt.Println(d, "=", r) } else { fmt.Println(d, "invalid decimal number") } } }
http://rosettacode.org/wiki/Copy_a_string
Copy a string
This task is about copying a string. Task Where it is relevant, distinguish between copying the contents of a string versus making an additional reference to an existing string. Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting W...
#AArch64_Assembly
AArch64 Assembly
  /* ARM assembly AARCH64 Raspberry PI 3B */ /* program copystr64.s */   /*******************************************/ /* Constantes file */ /*******************************************/ /* for this file see task include a file in language AArch64 assembly*/ .include "../includeConstantesARM6...
http://rosettacode.org/wiki/Copy_a_string
Copy a string
This task is about copying a string. Task Where it is relevant, distinguish between copying the contents of a string versus making an additional reference to an existing string. Other tasks related to string operations: Metrics Array length String length Copy a string Empty string  (assignment) Counting W...
#ABAP
ABAP
data: lv_string1 type string value 'Test', lv_string2 type string. lv_string2 = lv_string1.