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/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #SNOBOL4 | SNOBOL4 |
DEFINE("countSubstring(t,s)")
OUTPUT = countSubstring("the three truths","th")
OUTPUT = countSubstring("ababababab","abab")
:(END)
countSubstring t ARB s = :F(RETURN)
countSubstring = countSubstring + 1 :(countSubstring)
END
3
2
|
http://rosettacode.org/wiki/Count_in_octal | Count in octal | Task
Produce a sequential count in octal, starting at zero, and using an increment of a one for each consecutive number.
Each number should appear on a single line, and the program should count until terminated, or until the maximum value of the numeric type in use is reached.
Related task
Integer sequ... | #ZX_Spectrum_Basic | ZX Spectrum Basic | 10 PRINT "DEC. OCT."
20 FOR i=0 TO 20
30 LET o$="": LET n=i
40 LET o$=STR$ FN m(n,8)+o$
50 LET n=INT (n/8)
60 IF n>0 THEN GO TO 40
70 PRINT i;TAB 3;" = ";o$
80 NEXT i
90 STOP
100 DEF FN m(a,b)=a-INT (a/b)*b |
http://rosettacode.org/wiki/Count_in_factors | Count in factors | Task
Write a program which counts up from 1, displaying each number as the multiplication of its prime factors.
For the purpose of this task, 1 (unity) may be shown as itself.
Example
2 is prime, so it would be shown as itself.
6 is not prime; it would be shown as
2
×
3
{\di... | #Visual_Basic_.NET | Visual Basic .NET | Module CountingInFactors
Sub Main()
For i As Integer = 1 To 10
Console.WriteLine("{0} = {1}", i, CountingInFactors(i))
Next
For i As Integer = 9991 To 10000
Console.WriteLine("{0} = {1}", i, CountingInFactors(i))
Next
End Sub
Private Function Cou... |
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... | #PicoLisp | PicoLisp | (load "@lib/xhtml.l")
(<table> NIL NIL '(NIL (NIL "X") (NIL "Y") (NIL "Z"))
(for N 3
(<row> NIL N 124 456 789) ) ) |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #Toka | Toka | needs shell
" output.txt" "W" file.open file.close
" /output.txt" "W" file.open file.close
( Create the directories with permissions set to 777)
" docs" &777 mkdir
" /docs" &777 mkdir |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #TUSCRIPT | TUSCRIPT |
$$ MODE TUSCRIPT
- create file
ERROR/STOP CREATE ("output.txt",FDF-o,-std-)
- create directory
ERROR/STOP CREATE ("docs",project,-std-)
|
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... | #Rust | Rust | static INPUT : &'static str =
"Character,Speech
The multitude,The messiah! Show us the messiah!
Brians mother,<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitude,Who are you?
Brians mother,I'm his mother; that's who!
The multitude,Behold his mother! Behold his ... |
http://rosettacode.org/wiki/Cumulative_standard_deviation | Cumulative standard deviation | Task[edit]
Write a stateful function, class, generator or co-routine that takes a series of floating point numbers, one at a time, and returns the running standard deviation of the series.
The task implementation should use the most natural programming style of those listed for the function in the implementation langu... | #TI-83_BASIC | TI-83 BASIC | • Press [STAT] select [EDIT] followed by [ENTER]
• then enter for list L1 in the table : 2, 4, 4, 4, 5, 5, 7, 9
• Or enter {2,4,4,4,5,5,7,9}→L1
• Press [STAT] select [CALC] then [1-Var Stats] select list L1 followed by [ENTER]
• Then σx (=2) gives the standard deviation of the population
|
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #Standard_ML | Standard ML | fun count_substrings (str, sub) =
let
fun aux (str', count) =
let
val suff = #2 (Substring.position sub str')
in
if Substring.isEmpty suff then
count
else
aux (Substring.triml (size sub) suff, count + 1)
end
in
aux (Substring.full str, 0)
end;
... |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #Stata | Stata | function strcount(s, x) {
n = 0
k = 1-(i=strlen(x))
do {
if (k = ustrpos(s, x, k+i)) n++
} while(k)
return(n)
}
strcount("peter piper picked a peck of pickled peppers", "pe")
5
strcount("ababababab","abab")
2 |
http://rosettacode.org/wiki/Count_in_factors | Count in factors | Task
Write a program which counts up from 1, displaying each number as the multiplication of its prime factors.
For the purpose of this task, 1 (unity) may be shown as itself.
Example
2 is prime, so it would be shown as itself.
6 is not prime; it would be shown as
2
×
3
{\di... | #Vlang | Vlang | fn main() {
println("1: 1")
for i := 2; ; i++ {
print("$i: ")
mut x := ''
for n, f := i, 2; n != 1; f++ {
for m := n % f; m == 0; m = n % f {
print('$x$f')
x = "×"
n /= f
}
}
println('')
}
} |
http://rosettacode.org/wiki/Count_in_factors | Count in factors | Task
Write a program which counts up from 1, displaying each number as the multiplication of its prime factors.
For the purpose of this task, 1 (unity) may be shown as itself.
Example
2 is prime, so it would be shown as itself.
6 is not prime; it would be shown as
2
×
3
{\di... | #XPL0 | XPL0 | include c:\cxpl\codes;
int N0, N, F;
[N0:= 1;
repeat IntOut(0, N0); Text(0, " = ");
F:= 2; N:= N0;
repeat if rem(N/F) = 0 then
[if N # N0 then Text(0, " * ");
IntOut(0, F);
N:= N/F;
]
... |
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... | #PL.2FI | PL/I |
/* Create an HTML table. 6/2011 */
create: procedure options (main);
create_table: procedure (headings, table_contents);
declare headings(*) character (10) varying;
declare table_contents(*, *) fixed;
declare (i, row, col) fixed;
put skip edit ('<table>') (a);
/* Headings. */
put skip ed... |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #UNIX_Shell | UNIX Shell | touch output.txt /output.txt # create both output.txt and /output.txt
mkdir /docs
mkdir docs # create both /docs and docs |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #Ursa | Ursa | decl file f
f.create "output.txt"
f.createdir "docs"
# in the root directory
f.create "/output.txt"
f.createdir "/docs"
|
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... | #Scala | Scala | object CsvToHTML extends App {
val header = <head>
<title>CsvToHTML</title>
<style type="text/css">
td {{background-color:#ddddff; }} thead td {{background-color:#ddffdd; text-align:center; }}
</style>
</head>
val csv =
"""Character,Speech
|The multitude,The messiah! Show us the messia... |
http://rosettacode.org/wiki/Cumulative_standard_deviation | Cumulative standard deviation | Task[edit]
Write a stateful function, class, generator or co-routine that takes a series of floating point numbers, one at a time, and returns the running standard deviation of the series.
The task implementation should use the most natural programming style of those listed for the function in the implementation langu... | #VBScript | VBScript | data = Array(2,4,4,4,5,5,7,9)
For i = 0 To UBound(data)
WScript.StdOut.Write "value = " & data(i) &_
" running sd = " & sd(data,i)
WScript.StdOut.WriteLine
Next
Function sd(arr,n)
mean = 0
variance = 0
For j = 0 To n
mean = mean + arr(j)
Next
mean = mean/(n+1)
For k = 0 To n
variance = variance + ((ar... |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #Swift | Swift | import Foundation
func countSubstring(str: String, substring: String) -> Int {
return str.components(separatedBy: substring).count - 1
}
print(countSubstring(str: "the three truths", substring: "th"))
print(countSubstring(str: "ababababab", substring: "abab")) |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #Tcl | Tcl | proc countSubstrings {haystack needle} {
regexp -all ***=$needle $haystack
}
puts [countSubstrings "the three truths" "th"]
puts [countSubstrings "ababababab" "abab"]
puts [countSubstrings "abaabba*bbaba*bbab" "a*b"] |
http://rosettacode.org/wiki/Count_in_factors | Count in factors | Task
Write a program which counts up from 1, displaying each number as the multiplication of its prime factors.
For the purpose of this task, 1 (unity) may be shown as itself.
Example
2 is prime, so it would be shown as itself.
6 is not prime; it would be shown as
2
×
3
{\di... | #Wren | Wren | import "/math" for Int
for (r in [1..9, 2144..2154, 9987..9999]) {
for (i in r) {
var factors = (i > 1) ? Int.primeFactors(i) : [1]
System.print("%(i): %(factors.join(" x "))")
}
System.print()
} |
http://rosettacode.org/wiki/Count_in_factors | Count in factors | Task
Write a program which counts up from 1, displaying each number as the multiplication of its prime factors.
For the purpose of this task, 1 (unity) may be shown as itself.
Example
2 is prime, so it would be shown as itself.
6 is not prime; it would be shown as
2
×
3
{\di... | #zkl | zkl | foreach n in ([1..*]){ println(n,": ",primeFactors(n).concat("\U2715;")) } |
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... | #PowerShell | PowerShell |
# Converts Microsoft .NET Framework objects into HTML that can be displayed in a Web browser.
ConvertTo-Html -inputobject (Get-Date)
# Create a PowerShell object using a HashTable
$object = [PSCustomObject]@{
'A'=(Get-Random -Minimum 0 -Maximum 10);
'B'=(Get-Random -Minimum 0 -Maximum 10);
'... |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #VBA | VBA | Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #VBScript | VBScript |
Set objFSO = CreateObject("Scripting.FileSystemObject")
'current directory
objFSO.CreateFolder(".\docs")
objFSO.CreateTextFile(".\docs\output.txt")
'root directory
objFSO.CreateFolder("\docs")
objFSO.CreateTextFile("\docs\output.txt")
|
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... | #Sed | Sed | #!/bin/sed -f
s|<|\<|g
s|>|\>|g
s|^| <tr>\n <td>|
s|,|</td>\n <td>|
s|$|</td>\n </tr>|
1s|^|<table>\n|
$s|$|\n</table>| |
http://rosettacode.org/wiki/Cumulative_standard_deviation | Cumulative standard deviation | Task[edit]
Write a stateful function, class, generator or co-routine that takes a series of floating point numbers, one at a time, and returns the running standard deviation of the series.
The task implementation should use the most natural programming style of those listed for the function in the implementation langu... | #Visual_Basic | Visual Basic | Function avg(what() As Variant) As Variant
'treats non-numeric strings as zero
Dim L0 As Variant, total As Variant
For L0 = LBound(what) To UBound(what)
If IsNumeric(what(L0)) Then total = total + what(L0)
Next
avg = total / (1 + UBound(what) - LBound(what))
End Function
Function standardD... |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #Transd | Transd | #lang transd
MainModule: {
countSubstring: (λ s String() sub String()
(with n 0 pl 0
(while (> (= pl (find s sub pl)) -1)
(+= pl (size sub)) (+= n 1))
(lout n))
),
_start: (λ
(countSubstring "the three truths" "th")
(countSubstring "ababab... |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #TUSCRIPT | TUSCRIPT |
$$ MODE TUSCRIPT, {}
occurences=COUNT ("the three truths", ":th:")
occurences=COUNT ("ababababab", ":abab:")
occurences=COUNT ("abaabba*bbaba*bbab",":a\*b:")
|
http://rosettacode.org/wiki/Count_in_factors | Count in factors | Task
Write a program which counts up from 1, displaying each number as the multiplication of its prime factors.
For the purpose of this task, 1 (unity) may be shown as itself.
Example
2 is prime, so it would be shown as itself.
6 is not prime; it would be shown as
2
×
3
{\di... | #ZX_Spectrum_Basic | ZX Spectrum Basic | 10 FOR i=1 TO 20
20 PRINT i;" = ";
30 IF i=1 THEN PRINT 1: GO TO 90
40 LET p=2: LET n=i: LET f$=""
50 IF p>n THEN GO TO 80
60 IF NOT FN m(n,p) THEN LET f$=f$+STR$ p+" x ": LET n=INT (n/p): GO TO 50
70 LET p=p+1: GO TO 50
80 PRINT f$( TO LEN f$-3)
90 NEXT i
100 STOP
110 DEF FN m(a,b)=a-INT (a/b)*b |
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... | #Prolog | Prolog |
:- use_module(library(http/html_write)).
theader([]) --> []. theader([H|T]) --> html(th(H)), theader(T).
trows([],_) --> []. trows([R|T], N) --> html(tr([td(N),\trow(R)])), { N1 is N + 1 }, trows(T, N1).
trow([]) --> []. trow([E|T]) --> html(td(E)), trow(T).
table :-
Header = ['X','Y','Z'],
Rows = [
... |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #Vedit_macro_language | Vedit macro language | // In current directory
File_Open("input.txt") Ins_Char(' ') Del_Char(-1) Buf_Close()
File_Mkdir("docs")
// In the root directory
File_Open("/input.txt") Ins_Char(' ') Del_Char(-1) Buf_Close()
File_Mkdir("/docs") |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #Visual_Basic_.NET | Visual Basic .NET | 'Current Directory
IO.Directory.CreateDirectory("docs")
IO.File.Create("output.txt").Close()
'Root
IO.Directory.CreateDirectory("\docs")
IO.File.Create("\output.txt").Close()
'Root, platform independent
IO.Directory.CreateDirectory(IO.Path.DirectorySeparatorChar & "docs")
IO.File.Create(IO.Path.DirectorySeparato... |
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... | #Seed7 | Seed7 | $ include "seed7_05.s7i";
include "html_ent.s7i";
const string: csvData is "\
\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\
... |
http://rosettacode.org/wiki/Cumulative_standard_deviation | Cumulative standard deviation | Task[edit]
Write a stateful function, class, generator or co-routine that takes a series of floating point numbers, one at a time, and returns the running standard deviation of the series.
The task implementation should use the most natural programming style of those listed for the function in the implementation langu... | #Wren | Wren | import "/fmt" for Fmt
import "/math" for Nums
var cumStdDev = Fiber.new { |a|
for (i in 0...a.count) {
var b = a[0..i]
System.print("Values : %(b)")
Fiber.yield(Nums.popStdDev(b))
}
}
var a = [2, 4, 4, 4, 5, 5, 7, 9]
while (true) {
var sd = cumStdDev.call(a)
if (cumStdDev.i... |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #TXR | TXR | @(next :args)
@(do (defun count-occurrences (haystack needle)
(for* ((occurrences 0)
(old-pos 0)
(new-pos (search-str haystack needle old-pos nil)))
(new-pos occurrences)
((inc occurrences)
(set old-pos (+ new-pos (length needle)))
... |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #UNIX_Shell | UNIX Shell | #!/bin/bash
function countString(){
input=$1
cnt=0
until [ "${input/$2/}" == "$input" ]; do
input=${input/$2/}
let cnt+=1
done
echo $cnt
}
countString "the three truths" "th"
countString "ababababab" "abab" |
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... | #PureBasic | PureBasic |
Title.s="Create an HTML table"
head.s=""
head.s+"<html><head><title>"+Title.s+"</title></head><body>"+chr(13)+chr(10)
tablehead.s
tablehead.s+"<table border=1 cellpadding=10 cellspacing=0>"+chr(13)+chr(10)
tablehead.s+"<tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>"+chr(13)+chr(10)
index=0
tablebody.s=""
fo... |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #Visual_Objects | Visual Objects |
DirMake(String2Psz("c:\docs"))
FCreate("c:\docs\output.txt", FC_NORMAL)
|
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #Wren | Wren | import "io" for File
// file is closed automatically after creation
File.create("output.txt") {}
// check size
System.print("%(File.size("output.txt")) bytes") |
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... | #Sidef | Sidef | func escape(str) { str.trans(« & < > », « & < > ») }
func tag(t, d) { "<#{t}>#{d}</#{t}>" }
func csv2html(str) {
var template = <<-'EOT'
<!DOCTYPE html>
<html>
<head><title>Some Text</title></head>
<body><table>
%s
</table></body></html>
EOT
template.sprintf(escape(... |
http://rosettacode.org/wiki/Cumulative_standard_deviation | Cumulative standard deviation | Task[edit]
Write a stateful function, class, generator or co-routine that takes a series of floating point numbers, one at a time, and returns the running standard deviation of the series.
The task implementation should use the most natural programming style of those listed for the function in the implementation langu... | #XPL0 | XPL0 | include c:\cxpl\codes; \intrinsic 'code' declarations
int A, I;
real N, S, S2;
[A:= [2,4,4,4,5,5,7,9];
N:= 0.0; S:= 0.0; S2:= 0.0;
for I:= 0 to 8-1 do
[N:= N + 1.0;
S:= S + float(A(I));
S2:= S2 + float(sq(A(I)));
RlOut(0, sqrt((S2/N) - sq(S/N)));
];
CrLf(0);
] |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #VBA | VBA | Function CountStringInString(stLookIn As String, stLookFor As String)
CountStringInString = UBound(Split(stLookIn, stLookFor))
End Function |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #VBScript | VBScript |
Function CountSubstring(str,substr)
CountSubstring = 0
For i = 1 To Len(str)
If Len(str) >= Len(substr) Then
If InStr(i,str,substr) Then
CountSubstring = CountSubstring + 1
i = InStr(i,str,substr) + Len(substr) - 1
End If
Else
Exit For
End If
Next
End Function
WScript.StdOut.Write CountSub... |
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... | #Python | Python |
import random
def rand9999():
return random.randint(1000, 9999)
def tag(attr='', **kwargs):
for tag, txt in kwargs.items():
return '<{tag}{attr}>{txt}</{tag}>'.format(**locals())
if __name__ == '__main__':
header = tag(tr=''.join(tag(th=txt) for txt in ',X,Y,Z'.split(','))) + '\n'
rows =... |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #X86_Assembly | X86 Assembly |
; syscall numbers for readability. :]
%define sys_mkdir 39
%define sys_creat 8
section .data
fName db 'doc/output.txt',0
rfName db '/output.txt',0
dName db 'doc',0
err_msg db "Something went wrong! :[",0xa
err_len equ $-err_msg
section .text
global _start
_start:
nop
mov ebx... |
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... | #Tcl | Tcl | package require Tcl 8.5
package require csv
package require html
package require struct::queue
set csvData "Character,Speech
The multitude,The messiah! Show us the messiah!
Brians mother,<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitude,Who are you?
Brians m... |
http://rosettacode.org/wiki/Cumulative_standard_deviation | Cumulative standard deviation | Task[edit]
Write a stateful function, class, generator or co-routine that takes a series of floating point numbers, one at a time, and returns the running standard deviation of the series.
The task implementation should use the most natural programming style of those listed for the function in the implementation langu... | #zkl | zkl | fcn sdf{ fcn(x,xs){
m:=xs.append(x.toFloat()).sum(0.0)/xs.len();
(xs.reduce('wrap(p,x){(x-m)*(x-m) +p},0.0)/xs.len()).sqrt()
}.fp1(L())
} |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #Visual_Basic_.NET | Visual Basic .NET | Module Count_Occurrences_of_a_Substring
Sub Main()
Console.WriteLine(CountSubstring("the three truths", "th"))
Console.WriteLine(CountSubstring("ababababab", "abab"))
Console.WriteLine(CountSubstring("abaabba*bbaba*bbab", "a*b"))
Console.WriteLine(CountSubstring("abc", ""))
End S... |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #Vlang | Vlang | fn main(){
println('the three truths'.count('th'))
println('ababababab'.count('abab'))
} |
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... | #Racket | Racket |
#lang racket
(require xml)
(define xexpr
`(html
(head)
(body
(table
(tr (td) (td "X") (td "Y") (td "Z"))
,@(for/list ([i (in-range 1 4)])
`(tr (td ,(~a i))
(td ,(~a (random 10000)))
(td ,(~a (random 10000)))
(td ,(~a (random 10000))... |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #XPL0 | XPL0 |
int FD;
FD:= FOpen("output.txt", 1);
|
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #Yabasic | Yabasic | open "output.txt" for writing as #1
close #1
system("mkdir " + "f:\docs")
if open(2, "f:\docs\output.txt") then
print "Subdirectory or file already exists"
else
open "f:\docs\output.txt" for writing as #2
close #2
end if |
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... | #TUSCRIPT | TUSCRIPT |
$$ MODE TUSCRIPT
MODE DATA
$$ csv=*
Character,Speech
The multitude,The messiah! Show us the messiah!
Brians mother,<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>
The multitude,Who are you?
Brians mother,I'm his mother; that's who!
The multitude,Behold his mother! Behol... |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #Wortel | Wortel | @let {
c &[s t] #!s.match &(t)g
[[
!!c "the three truths" "th"
!!c "ababababab" "abab"
]]
} |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #Wren | Wren | import "/pattern" for Pattern
import "/fmt" for Fmt
var countSubstring = Fn.new { |str, sub|
var p = Pattern.new(sub)
return p.findAll(str).count
}
var tests = [
["the three truths", "th"],
["ababababab", "abab"],
["abaabba*bbaba*bbab", "a*b"],
["aaaaaaaaaaaaaa", "aa"],
["aaaaaaaaaaaaaa"... |
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... | #Raku | Raku | my @header = < X Y Z>;
my $rows = 5;
sub tag ($tag, $string, $param?) { return "<$tag" ~ ($param ?? " $param" !! '') ~ ">$string" ~ "</$tag>" };
my $table = tag('tr', ( tag('th', $_) for @header));
for 1 .. $rows -> $row {
$table ~= tag('tr', ( tag('td', $row, 'align="right"')
~ (tag('td', (^1000... |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #zkl | zkl | $ ls -l docs
ls: cannot access docs: No such file or directory
$ zkl
zkl: fcn createOutputTxt(dir){ dir=dir+"/docs"; File.mkdir(dir); File(dir+"/output.txt","w") }
Void
zkl: createOutputTxt(".")
File(./docs/output.txt)
zkl: createOutputTxt("/")
Stack trace for VM#1 ... |
http://rosettacode.org/wiki/Create_a_file | Create a file | In this task, the job is to create a new empty file called "output.txt" of size 0 bytes
and an empty directory called "docs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
| #ZX_Spectrum_Basic | ZX Spectrum Basic | SAVE "OUTPUT" CODE 16384,0 |
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... | #TXR | TXR | @(collect)
@char,@speech
@(end)
@(output :filter :to_html)
<table>
@ (repeat)
<tr>
<td>@char</td>
<td>@speech</td>
</tr>
@ (end)
</table>
@(end) |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #XPL0 | XPL0 | include c:\cxpl\codes; \intrinsic 'code' declarations
string 0; \use zero-terminated strings, instead of MSb terminated
func StrNCmp(A, B, N); \Compare string A to string B up to N bytes long
\This returns:
\ >0 if A > B
\ =0 if A = B
\ <0 if A < B
char A, B; \string... |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #zkl | zkl | fcn countSubstring(s,p){ pn:=p.len(); cnt:=n:=0;
while(Void!=(n:=s.find(p,n))){cnt+=1; n+=pn}
cnt
} |
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.
| #8086_Assembly | 8086 Assembly | READ: equ 3Fh ; MS-DOS syscalls
WRITE: equ 40h
BUFSZ: equ 4000h ; Buffer size
cpu 8086
bits 16
org 100h
section .text
read: mov ah,READ ; Read into buffer
xor bx,bx ; From STDIN (file 0)
mov cx,BUFSZ
mov dx,buffer
int 21h
test ax,ax ; Did we read anything?
jz done ; If not, stop
xchg ax,cx ; Write as m... |
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... | #Rascal | Rascal | import IO;
import util::Math;
str html(str title, str content) = item("html", item("title", title) + item("body", content));
str item(str op, str content) = "\<<op>\><content>\</<op>\>";
str table(str content) = item("table border=\"0\"", content);
str tr(str content) = item("tr", content);
str td(str content) = item... |
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... | #UNIX_Shell | UNIX Shell | csv2html() {
IFS=,
echo "<table>"
echo "<thead>"
read -a fields
htmlrow th "${fields[@]}"
echo "</thead>"
echo "<tbody>"
while read -a fields
do htmlrow td "${fields[@]}"
done
echo "</tbody>"
echo "</table>"
}
htmlrow() {
cell=$1
shift
echo "<tr>"
for field
... |
http://rosettacode.org/wiki/Count_occurrences_of_a_substring | Count occurrences of a substring | Task
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
The function should take two arguments:
the first argument being the string to search, and
the second a substring to be searched for.
It should return an integer cou... | #ZX_Spectrum_Basic | ZX Spectrum Basic | 10 LET t$="ABABABABAB": LET p$="ABAB": GO SUB 1000
20 LET t$="THE THREE TRUTHS": LET p$="TH": GO SUB 1000
30 STOP
1000 PRINT t$: LET c=0
1010 LET lp=LEN p$
1020 FOR i=1 TO LEN t$-lp+1
1030 IF (t$(i TO i+lp-1)=p$) THEN LET c=c+1: LET i=i+lp-1
1040 NEXT i
1050 PRINT p$;"=";c''
1060 RETURN |
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.
| #Action.21 | Action! | PROC Main()
CHAR c
DO
c=GetD(7)
Put(c)
UNTIL c=27 ;repeat until Esc key is pressed
OD
RETURN |
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.
| #Ada | Ada | with Ada.Text_IO;
procedure Copy_Stdin_To_Stdout is
use Ada.Text_IO;
C : Character;
begin
while not End_Of_File loop
Get_Immediate (C);
Put (C);
end loop;
end Copy_Stdin_To_Stdout; |
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.
| #Aime | Aime | file f;
data b;
f.stdin;
while (f.b_line(b) ^ -1) {
o_(b, "\n");
} |
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.
| #ALGOL_68 | ALGOL 68 | BEGIN
BOOL at eof := FALSE;
# set the EOF handler for stand in to a procedure that sets "at eof" to true #
# and returns true so processing can continue #
on logical file end( stand in, ( REF FILE f )BOOL: at eof := TRUE );
# copy stand i... |
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... | #Red | Red |
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 r... |
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... | #VBA | VBA | Public Sub CSV_TO_HTML()
input_ = "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" & _
... |
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.
| #Applesoft_BASIC | Applesoft BASIC | 0 GET C$ : PRINT C$; : GOTO |
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.
| #AWK | AWK | awk "//" |
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.
| #BCPL | BCPL | get "libhdr"
let start() be
$( let c = rdch()
if c = endstreamch then finish
wrch(c)
$) repeat |
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.
| #Brainf.2A.2A.2A | Brainf*** | ,[.,] |
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... | #Retro | Retro | needs casket::html'
with casket::html'
: rnd ( -$ ) random 1000 mod toString ;
[ [ [ ] td [ "x" ] td [ "y" ] td [ "z" ] td ] tr
[ [ "1" ] td [ rnd ] td [ rnd ] td [ rnd ] td ] tr
[ [ "2" ] td [ rnd ] td [ rnd ] td [ rnd ] td ] tr
[ [ "3" ] td [ rnd ] td [ rnd ] td [ rnd ] td ] tr
[ [ "4" ] td [ rnd ] td... |
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... | #VBScript | VBScript |
Set objfso = CreateObject("Scripting.FileSystemObject")
parent_folder = objfso.GetParentFolderName(WScript.ScriptFullName) & "\"
Set objcsv = objfso.OpenTextFile(parent_folder & "in.csv",1,False)
Set objhtml = objfso.OpenTextFile(paren_folder & "out.html",2,True)
objhtml.Write(csv_to_html(objcsv.ReadAll))
obj... |
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.
| #C | C |
#include <stdio.h>
int main(){
char c;
while ( (c=getchar()) != EOF ){
putchar(c);
}
return 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.
| #C.23 | C# |
using System;
class Program
{
static void Main(string[] args)
{
Console.OpenStandardInput().CopyTo(Console.OpenStandardOutput());
}
}
|
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.
| #C.2B.2B | C++ | #include <iostream>
#include <iterator>
int main() {
using namespace std;
noskipws(cin);
copy(
istream_iterator<char>(cin),
istream_iterator<char>(),
ostream_iterator<char>(cout)
);
return 0;
} |
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... | #REXX | REXX | /*REXX program creates (and displays) an HTML table of five rows and three columns.*/
parse arg rows . /*obtain optional argument from the CL.*/
if rows=='' | rows=="," then rows=5 /*no ROWS specified? Then use default.*/
cols = 3 ... |
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... | #Vedit_macro_language | Vedit macro language | if (BB < 0) { // block not set
BB(0) // convert entire file
BE(File_Size)
}
// Convert special characters into entities
Replace_Block("&","&", BB, BE, BEGIN+ALL+NOERR)
Replace_Block("<","<", BB, BE, BEGIN+ALL+NOERR)
Replace_Block(">",">", BB, BE, BEGIN+ALL+NOERR)
// Convert... |
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.
| #CLU | CLU | start_up = proc ()
pi: stream := stream$primary_input()
po: stream := stream$primary_output()
while true do
stream$putc(po, stream$getc(pi))
end except when end_of_file:
return
end
end start_up |
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.
| #Commodore_BASIC | Commodore BASIC | 10 print chr$(147);chr$(14);
11 print "0:Keyboard 1:Tape 2:RS-232 3:Screen"
12 print "4-7:printers/plotters"
13 print "8-11:Disk Drives":print
14 input "Input device";d1
15 if d1=1 or d1>=8 then input "Filename for INPUT";i$
16 input "Output device";d2
17 if d2=1 or d2>=8 then input "Filename for OUTPUT";o$
18 print... |
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.
| #Common_Lisp | Common Lisp | #|Loops while reading and collecting characters from STDIN until EOF (C-Z or C-D)
Then concatenates the characters into a string|#
(format t
(concatenate 'string
(loop for x = (read-char *query-io*) until (or (char= x #\Sub) (char= x #\Eot)) collecting x)))
|
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... | #Ring | Ring |
# Project: Create an HTML table
load "stdlib.ring"
str = ""
ncols = 3
nrows = 4
str = str + "<html><head></head><body>" + windowsnl()
str = str + "<table border=1 cellpadding=10 cellspacing=0>" + windowsnl()
for row = 0 to nrows
if row = 0
str = str + "<tr><th></th>"
else
str = str +... |
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... | #Visual_Basic_.NET | Visual Basic .NET | Imports Microsoft.VisualBasic.FileIO
Module Program
Sub Main(args As String())
Dim parser As TextFieldParser
Try
If args.Length > 1 Then
parser = My.Computer.FileSystem.OpenTextFieldParser(args(1), ",")
Else
parser = New TextFieldParser(Conso... |
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.
| #Crystal | Crystal | STDIN.each_line do |line|
puts line
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.
| #D | D | import std.stdio;
void main() {
foreach (line; stdin.byLine) {
writeln(line);
}
} |
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.
| #Dart | Dart | import 'dart:io';
void main() {
var line = stdin.readLineSync();
stdout.write(line);
} |
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.
| #Delphi | Delphi | \util.g
proc nonrec main() void:
char c;
while
/* I/O is line-oriented, so first read characters
* from the current line while that is possible */
while read(c) do write(c) od;
case ioerror()
/* Then once it fails, if the line is empty,
* try to go to ... |
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... | #Ruby | Ruby |
def r
rand(10000)
end
STDOUT << "".tap do |html|
html << "<table>"
[
['X', 'Y', 'Z'],
[r ,r ,r],
[r ,r ,r],
[r ,r ,r],
[r ,r ,r]
].each_with_index do |row, index|
html << "<tr>"
html << "<td>#{index > 0 ? index : nil }</td>"
html << row.map { |e| "<td>#{e}</td>"}.join
h... |
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... | #Wren | Wren | var csv =
"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" +
"Th... |
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.
| #Draco | Draco | \util.g
proc nonrec main() void:
char c;
while
/* I/O is line-oriented, so first read characters
* from the current line while that is possible */
while read(c) do write(c) od;
case ioerror()
/* Then once it fails, if the line is empty,
* try to go to ... |
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.
| #F.23 | F# |
let copy()=let n,g=stdin,stdout
let rec fN()=match n.ReadLine() with "EOF"->g.Write "" |i->g.WriteLine i; fN()
fN()
copy()
|
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.
| #Factor | Factor | USING: io kernel ;
[ read1 dup ] [ write1 ] while drop |
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.
| #Forth | Forth | stdin slurp-fid type bye |
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... | #Run_BASIC | Run BASIC | html "<table border=1><tr align=center><td>Row</td><td>X</td><td>Y</td><td>Z</td></tr>"
for i = 1 to 5
html "<tr align=right>"
for j = 1 to 4
if j = 1 then html "<td>";i;"</td>" else html "<td>";i;j;"</td>"
next j
html "</tr>"
next i
html "</table>" |
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... | #XSLT_2.0 | XSLT 2.0 | <xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xcsvt="http://www.seanbdurkin.id.au/xslt/csv-to-xml.xslt"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xcsv="http://www.seanbdurkin.id.au/xslt/xcsv.xsd"
version="2.0"
exclude-result-prefixes="xsl xs xcsvt xcsv">
<xsl:impo... |
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.
| #FreeBASIC | FreeBASIC | #define FIN 255 'eof is already a reserved word
#include "crt/stdio.bi" 'provides the C functions getchar and putchar
dim as ubyte char
do
char = getchar()
if char = FIN then exit do else putchar(char)
loop |
Subsets and Splits
Rosetta Code COBOL Python Hard Tasks
Identifies and retrieves challenging tasks that exist in both COBOL and Python, revealing cross-language programming patterns and difficulty levels for comparative analysis.
Rosetta Code Task Comparisons
Identifies tasks common to both COBOL and Python languages that are described as having difficulty levels, revealing cross-language task similarities and providing useful comparative programming examples.
SQL Code Examples from Training Data
Retrieves raw SQL code examples for the SQL language, which is basic data retrieval without meaningful analysis or patterns.
SQL Code Examples from Training Data
Retrieves raw SQL code examples for the SQL language, which is basic filtering that shows what data looks like but doesn't provide meaningful analysis or patterns.
Select Specific Languages Codes
Retrieves specific programming language names and codes from training data, providing basic filtering but limited analytical value beyond identifying these particular languages.