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/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Bc | Bc | $ echo 'print "Hello "; var=99; ++var + 20 + 3' | bc |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Bracmat | Bracmat | bracmat "put$tay$(e^x,x,20)&" |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Burlesque | Burlesque |
Burlesque.exe --no-stdin "5 5 .+"
|
http://rosettacode.org/wiki/Show_ASCII_table | Show ASCII table | Task
Show the ASCII character set from values 32 to 127 (decimal) in a table format.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioin... | #8080_Assembly | 8080 Assembly | org 100h
mvi a,32 ; Start with space
mvi d,16 ; 16 lines
dochar: mov c,a ; Print number
call putnum
mov a,c
lxi h,spc ; Is it space?
cpi 32
jz print
lxi h,del
cpi 127 ; Is it del?
jz print
lxi h,chr ; Character
mov m,a
print: call puts
adi 16 ; Next column
jp dochar ; Done with this line?
lxi h,... |
http://rosettacode.org/wiki/Simple_database | Simple database | Task
Write a simple tool to track a small set of data.
The tool should have a command-line interface to enter at least two different values.
The entered data should be stored in a structured format and saved to disk.
It does not matter what kind of data is being tracked. It could be a collection (CDs, coins, base... | #Nim | Nim | import algorithm, json, os, strformat, strutils, times
const FileName = "simdb.json"
type
Item = object
name: string
date: string
category: string
Database = seq[Item]
DbError = object of CatchableError
proc load(): Database =
if fileExists(FileName):
let node = try: FileName.parse... |
http://rosettacode.org/wiki/Simple_database | Simple database | Task
Write a simple tool to track a small set of data.
The tool should have a command-line interface to enter at least two different values.
The entered data should be stored in a structured format and saved to disk.
It does not matter what kind of data is being tracked. It could be a collection (CDs, coins, base... | #Perl | Perl | #!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };
use JSON::PP;
use Time::Piece;
use constant {
NAME => 0,
CATEGORY => 1,
DATE => 2,
DB => 'simple-db',
};
my $operation = shift // "";
my %dispatch = (
n => \&add_new,
l => \&print_latest,
L => \&print_late... |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #PicoLisp | PicoLisp | : (date 1)
-> (0 3 1) # Year zero, March 1st |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Pike | Pike |
object cal = Calendar.ISO->set_timezone("UTC");
write( cal.Second(0)->format_iso_short() );
|
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #PL.2FI | PL/I | *process source attributes xref;
epoch: Proc Options(main);
/*********************************************************************
* 20.08.2013 Walter Pachl shows that PL/I uses 15 Oct 1582 as epoch
* DAYS returns a FIXED BINARY(31,0) value which is the number of days
* (in Lilian format) corresponding to the dat... |
http://rosettacode.org/wiki/Sierpinski_triangle | Sierpinski triangle | Task
Produce an ASCII representation of a Sierpinski triangle of order N.
Example
The Sierpinski triangle of order 4 should look like this:
*
* *
* *
* * * *
* *
* * * *
... | #F.23 | F# | let sierpinski n =
let rec loop down space n =
if n = 0 then
down
else
loop (List.map (fun x -> space + x + space) down @
List.map (fun x -> x + " " + x) down)
(space + space)
(n - 1)
in loop ["*"] " " n
let () =
List.iter (fun (i:string) -> System.Console.Write... |
http://rosettacode.org/wiki/Sierpinski_carpet | Sierpinski carpet | Task
Produce a graphical or ASCII-art representation of a Sierpinski carpet of order N.
For example, the Sierpinski carpet of order 3 should look like this:
###########################
# ## ## ## ## ## ## ## ## #
###########################
### ###### ###### ###
# # # ## # # ## # # #
### ###### ... | #BASIC256 | BASIC256 |
function in_carpet(x, y)
while x <> 0 and y <> 0
if(x mod 3) = 1 and (y mod 3) = 1 then return False
y = int(y / 3): x = int(x / 3)
end while
return True
end function
Subroutine carpet(n)
k = (3^n)-1
for i = 0 to k
for j = 0 to k
if in_carpet(i, j) then print("#"); else print(" ");
next j
print
... |
http://rosettacode.org/wiki/Shoelace_formula_for_polygonal_area | Shoelace formula for polygonal area | Given the n + 1 vertices x[0], y[0] .. x[N], y[N] of a simple polygon described in a clockwise direction, then the polygon's area can be calculated by:
abs( (sum(x[0]*y[1] + ... x[n-1]*y[n]) + x[N]*y[0]) -
(sum(x[1]*y[0] + ... x[n]*y[n-1]) + x[0]*y[N])
) / 2
(Where abs returns the absolute value)
Task
Write ... | #F.23 | F# |
// Shoelace formula for area of polygon. Nigel Galloway: April 11th., 2018
let fN(n::g) = abs(List.pairwise(n::g@[n])|>List.fold(fun n ((nα,gα),(nβ,gβ))->n+(nα*gβ)-(gα*nβ)) 0.0)/2.0
printfn "%f" (fN [(3.0,4.0); (5.0,11.0); (12.0,8.0); (9.0,5.0); (5.0,6.0)]) |
http://rosettacode.org/wiki/Shoelace_formula_for_polygonal_area | Shoelace formula for polygonal area | Given the n + 1 vertices x[0], y[0] .. x[N], y[N] of a simple polygon described in a clockwise direction, then the polygon's area can be calculated by:
abs( (sum(x[0]*y[1] + ... x[n-1]*y[n]) + x[N]*y[0]) -
(sum(x[1]*y[0] + ... x[n]*y[n-1]) + x[0]*y[N])
) / 2
(Where abs returns the absolute value)
Task
Write ... | #Factor | Factor | USING: circular kernel math prettyprint sequences ;
IN: rosetta-code.shoelace
CONSTANT: input { { 3 4 } { 5 11 } { 12 8 } { 9 5 } { 5 6 } }
: align-pairs ( pairs-seq -- seq1 seq2 )
<circular> dup clone [ 1 ] dip
[ change-circular-start ] keep ;
: shoelace-sum ( seq1 seq2 -- n )
[ [ first ] [ second ] ... |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #C | C | $ echo 'main() {printf("Hello\n");}' | gcc -w -x c -; ./a.out |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #C.23 | C# | > Add-Type -TypeDefinition "public class HelloWorld { public static void SayHi() { System.Console.WriteLine(""Hi!""); } }"
> [HelloWorld]::SayHi()
Hi! |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Clojure | Clojure | $ clj-env-dir -e "(defn add2 [x] (inc (inc x))) (add2 40)"
#'user/add2
42 |
http://rosettacode.org/wiki/Short-circuit_evaluation | Short-circuit evaluation | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Assume functions a and b return boolean values, and further, the execution of function b takes considerable resources without side effects, an... | #11l | 11l | F a(v)
print(‘ ## Called function a(#.)’.format(v))
R v
F b(v)
print(‘ ## Called function b(#.)’.format(v))
R v
L(i) (0B, 1B)
L(j) (0B, 1B)
print("\nCalculating: x = a(i) and b(j)")
V x = a(i) & b(j)
print(‘Calculating: y = a(i) or b(j)’)
V y = a(i) | b(j) |
http://rosettacode.org/wiki/Show_ASCII_table | Show ASCII table | Task
Show the ASCII character set from values 32 to 127 (decimal) in a table format.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioin... | #8086_Assembly | 8086 Assembly | cpu 8086
bits 16
putch: equ 2h
section .text
org 100h
mov cx,16 ; 16 lines
mov bh,32 ; Start at 32
dochar: mov al,bh ; Print number
call putnum
cmp bh,32 ; Space?
je .spc
cmp bh,127 ; Del?
je .del
mov [chr],bh ; Otherwise, print character
mov di,chr
jmp .out
.spc: mov di,spc
jmp .out
.del: mov di... |
http://rosettacode.org/wiki/Simple_database | Simple database | Task
Write a simple tool to track a small set of data.
The tool should have a command-line interface to enter at least two different values.
The entered data should be stored in a structured format and saved to disk.
It does not matter what kind of data is being tracked. It could be a collection (CDs, coins, base... | #Phix | Phix | --
-- demo\rosetta\Simple_db.exw
-- ==========================
--
without js -- (file i/o, gets(0), getenv)
include timedate.e
constant filename = getenv(iff(platform()=WINDOWS?"APPDATA":"HOME"))&"/simple_db.csv"
procedure add(sequence cmd)
if length(cmd)=0
or length(cmd)>2 then
printf(1,"usage: add ... |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #PowerShell | PowerShell | [datetime] 0 |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #PureBasic | PureBasic | If OpenConsole()
PrintN(FormatDate("Y = %yyyy M = %mm D = %dd, %hh:%ii:%ss", 0))
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
CloseConsole()
EndIf |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Python | Python | >>> import time
>>> time.asctime(time.gmtime(0))
'Thu Jan 1 00:00:00 1970'
>>> |
http://rosettacode.org/wiki/Sierpinski_triangle | Sierpinski triangle | Task
Produce an ASCII representation of a Sierpinski triangle of order N.
Example
The Sierpinski triangle of order 4 should look like this:
*
* *
* *
* * * *
* *
* * * *
... | #Factor | Factor | USING: io kernel math sequences ;
IN: sierpinski
: iterate-triangle ( triange spaces -- triangle' )
[ [ dup surround ] curry map ]
[ drop [ dup " " glue ] map ] 2bi append ;
: (sierpinski) ( triangle spaces n -- triangle' )
dup 0 = [ 2drop "\n" join ] [
[
[ iterate-triangle ]
... |
http://rosettacode.org/wiki/Sierpinski_carpet | Sierpinski carpet | Task
Produce a graphical or ASCII-art representation of a Sierpinski carpet of order N.
For example, the Sierpinski carpet of order 3 should look like this:
###########################
# ## ## ## ## ## ## ## ## #
###########################
### ###### ###### ###
# # # ## # # ## # # #
### ###### ... | #BBC_BASIC | BBC BASIC | Order% = 3
side% = 3^Order%
VDU 23,22,8*side%;8*side%;64,64,16,128
FOR Y% = 0 TO side%-1
FOR X% = 0 TO side%-1
IF FNincarpet(X%,Y%) PLOT X%*16,Y%*16+15
NEXT
NEXT Y%
REPEAT WAIT 1 : UNTIL FALSE
END
DEF FNincarpet(X%,Y%)
REPEAT
IF X... |
http://rosettacode.org/wiki/Shoelace_formula_for_polygonal_area | Shoelace formula for polygonal area | Given the n + 1 vertices x[0], y[0] .. x[N], y[N] of a simple polygon described in a clockwise direction, then the polygon's area can be calculated by:
abs( (sum(x[0]*y[1] + ... x[n-1]*y[n]) + x[N]*y[0]) -
(sum(x[1]*y[0] + ... x[n]*y[n-1]) + x[0]*y[N])
) / 2
(Where abs returns the absolute value)
Task
Write ... | #Fortran | Fortran | DOUBLE PRECISION FUNCTION AREA(N,P) !Calculates the area enclosed by the polygon P.
C Uses the mid-point rule for integration. Consider the line joining (x1,y1) to (x2,y2)
C The area under that line (down to the x-axis) is the y-span midpoint (y1 + y2)/2 times the width (x2 - x1)
C This is the trapezoidal rule ... |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #CMake | CMake | echo 'message(STATUS "Goodbye, World!")' | cmake -P /dev/stdin |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #COBOL | COBOL | echo 'display "hello".' | cobc -xFj -frelax - |
http://rosettacode.org/wiki/Short-circuit_evaluation | Short-circuit evaluation | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Assume functions a and b return boolean values, and further, the execution of function b takes considerable resources without side effects, an... | #6502_Assembly | 6502 Assembly | ;DEFINE 0 AS FALSE, $FF as true.
False equ 0
True equ 255
Func_A:
;input: accumulator = value to check. 0 = false, nonzero = true.
;output: 0 if false, 255 if true. Also prints the truth value to the screen.
;USAGE: LDA val JSR Func_A
BEQ .falsehood
load16 z_HL,BoolText_A_True ;lda #<BoolText_A_True sta z_L lda #>... |
http://rosettacode.org/wiki/Short-circuit_evaluation | Short-circuit evaluation | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Assume functions a and b return boolean values, and further, the execution of function b takes considerable resources without side effects, an... | #Action.21 | Action! | BYTE FUNC a(BYTE x)
PrintF(" a(%B)",x)
RETURN (x)
BYTE FUNC b(BYTE x)
PrintF(" b(%B)",x)
RETURN (x)
PROC Main()
BYTE i,j
FOR i=0 TO 1
DO
FOR j=0 TO 1
DO
PrintF("Calculating %B AND %B: call",i,j)
IF a(i)=1 AND b(j)=1 THEN
FI
PutE()
OD
OD
PutE()
FOR i=0 TO 1
D... |
http://rosettacode.org/wiki/Show_ASCII_table | Show ASCII table | Task
Show the ASCII character set from values 32 to 127 (decimal) in a table format.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioin... | #Action.21 | Action! | PROC Main()
BYTE
count=[96],rows=[16],
first=[32],last=[127],
i,j
Put(125) ;clear screen
FOR i=0 TO rows-1
DO
Position(2,3+i)
FOR j=first+i TO last STEP rows
DO
IF j>=96 AND j<=99 THEN
Put(' )
FI
PrintB(j)
Put(' )
IF j=32 THEN
Print("... |
http://rosettacode.org/wiki/Simple_database | Simple database | Task
Write a simple tool to track a small set of data.
The tool should have a command-line interface to enter at least two different values.
The entered data should be stored in a structured format and saved to disk.
It does not matter what kind of data is being tracked. It could be a collection (CDs, coins, base... | #PicoLisp | PicoLisp | #!/usr/bin/pil
(de usage ()
(prinl
"Usage:^J\
sdb <file> add <title> <cat> <date> ... Add a new entry^J\
sdb <file> get <title> Retrieve an entry^J\
sdb <file> latest Print the latest entry^J\
sdb <file> categories Print the... |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #R | R | > epoch <- 0
> class(epoch) <- class(Sys.time())
> format(epoch, "%Y-%m-%d %H:%M:%S %Z")
[1] "1970-01-01 00:00:00 UTC" |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Racket | Racket |
#lang racket
(require racket/date)
(date->string (seconds->date 0 #f))
|
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Raku | Raku | say DateTime.new(0) |
http://rosettacode.org/wiki/Sierpinski_triangle | Sierpinski triangle | Task
Produce an ASCII representation of a Sierpinski triangle of order N.
Example
The Sierpinski triangle of order 4 should look like this:
*
* *
* *
* * * *
* *
* * * *
... | #FALSE | FALSE | [[$][$1&["*"]?$~1&[" "]?2/]#%"
"]s: { stars }
[$@$@|@@&~&]x: { xor }
[1\[$][1-\2*\]#%]e: { 2^n }
[e;!1\[$][\$s;!$2*x;!\1-]#%%]t:
4t;! |
http://rosettacode.org/wiki/Sierpinski_carpet | Sierpinski carpet | Task
Produce a graphical or ASCII-art representation of a Sierpinski carpet of order N.
For example, the Sierpinski carpet of order 3 should look like this:
###########################
# ## ## ## ## ## ## ## ## #
###########################
### ###### ###### ###
# # # ## # # ## # # #
### ###### ... | #Befunge | Befunge | 311>*#3\>#-:#1_$:00p00g-#@_010p0>:20p10g30v
>p>40p"#"30g40g*!#v_$48*30g3%1-v^ >$55+,1v>
0 ^p03/3g03/3g04$_v#!*!-1%3g04!<^_^#- g00 <
^3g01p02:0p01_@#-g>#0,#02#:0#+g#11#g+#0:#<^ |
http://rosettacode.org/wiki/Shoelace_formula_for_polygonal_area | Shoelace formula for polygonal area | Given the n + 1 vertices x[0], y[0] .. x[N], y[N] of a simple polygon described in a clockwise direction, then the polygon's area can be calculated by:
abs( (sum(x[0]*y[1] + ... x[n-1]*y[n]) + x[N]*y[0]) -
(sum(x[1]*y[0] + ... x[n]*y[n-1]) + x[0]*y[N])
) / 2
(Where abs returns the absolute value)
Task
Write ... | #FreeBASIC | FreeBASIC | ' version 18-08-2017
' compile with: fbc -s console
Type _point_
As Double x, y
End Type
Function shoelace_formula(p() As _point_ ) As Double
Dim As UInteger i
Dim As Double sum
For i = 1 To UBound(p) -1
sum += p(i ).x * p(i +1).y
sum -= p(i +1).x * p(i ).y
Next
sum +... |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Common_Lisp | Common Lisp | sbcl --noinform --eval '(progn (princ "Hello") (terpri) (quit))' |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #D | D | rdmd --eval="writeln(q{Hello World!})" |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Dc | Dc | dc -e '22 7/p' |
http://rosettacode.org/wiki/Short-circuit_evaluation | Short-circuit evaluation | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Assume functions a and b return boolean values, and further, the execution of function b takes considerable resources without side effects, an... | #Ada | Ada | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Short_Circuit is
function A (Value : Boolean) return Boolean is
begin
Put (" A=" & Boolean'Image (Value));
return Value;
end A;
function B (Value : Boolean) return Boolean is
begin
Put (" B=" & Boolean'Image (Value));
return Val... |
http://rosettacode.org/wiki/Show_ASCII_table | Show ASCII table | Task
Show the ASCII character set from values 32 to 127 (decimal) in a table format.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioin... | #Ada | Ada | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Ascii_Table is
N : Integer;
begin
for R in 0 .. 15 loop
for C in 0 .. 5 loop
N := 32 + 16 * C + R;
Put (N, 3);
Put (" : ");
case N is
when 32 =>
... |
http://rosettacode.org/wiki/Simple_database | Simple database | Task
Write a simple tool to track a small set of data.
The tool should have a command-line interface to enter at least two different values.
The entered data should be stored in a structured format and saved to disk.
It does not matter what kind of data is being tracked. It could be a collection (CDs, coins, base... | #Pike | Pike | mapping db = ([]);
mapping make_episode(string series, string title, string episode, array date)
{
return ([ "series":series, "episode":episode, "title":title, "date":date ]);
}
void print_episode(mapping episode)
{
write(" %-30s %10s %-30s (%{%d.%})\n",
episode->series, episode->episode, episod... |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #REXX | REXX | /*REXX program displays the number of days since the epoch for the DATE function (BIF). */
say ' today is: ' date() /*today's is format: mm MON YYYY */
days=date('Basedate') /*only the first char of option is used*/
say right(days, 40) " days since th... |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Ring | Ring |
load "guilib.ring"
New qApp {
win1 = new qMainWindow() {
setwindowtitle("Using QDateEdit")
setGeometry(100,100,250,100)
oDate = new qdateedit(win1) {
setGeometry(20,40,220,30)
oDate.minimumDate()
}
... |
http://rosettacode.org/wiki/Sierpinski_triangle | Sierpinski triangle | Task
Produce an ASCII representation of a Sierpinski triangle of order N.
Example
The Sierpinski triangle of order 4 should look like this:
*
* *
* *
* * * *
* *
* * * *
... | #FOCAL | FOCAL | 01.10 A "ORDER",O;S S=2^(O+1)
01.20 F X=0,S;S L(X)=0
01.30 S L(S/2)=1
01.40 F I=1,S/2;D 2;D 3
01.90 Q
02.10 F X=1,S-1;D 2.3
02.20 T !;R
02.30 I (L(X)),2.4,2.5
02.40 T " "
02.50 T "*"
03.10 F X=0,S;S K(X)=FABS(L(X-1)-L(X+1))
03.20 F X=0,S;S L(X)=K(X) |
http://rosettacode.org/wiki/Sierpinski_carpet | Sierpinski carpet | Task
Produce a graphical or ASCII-art representation of a Sierpinski carpet of order N.
For example, the Sierpinski carpet of order 3 should look like this:
###########################
# ## ## ## ## ## ## ## ## #
###########################
### ###### ###### ###
# # # ## # # ## # # #
### ###### ... | #BQN | BQN | _decode ← {⌽𝕗|⌊∘÷⟜𝕗⍟(↕1+·⌊𝕗⋆⁼1⌈⊢)}
Carpet ← { # 2D Array method using ∾.
{∾(3‿3⥊4≠↕9)⊏⟨(≢𝕩)⥊0,𝕩⟩}⍟(𝕩-1) 1‿1⥊1
}
Carpet1 ← { # base conversion method, works in a single step.
¬{∨´𝕨∧○((-𝕨⌈○≠𝕩)⊸↑)𝕩}⌜˜2|3 _decode¨↕3⋆𝕩-1
}
•Show " #"⊏˜Carpet 4
•Show (Carpet ≡ Carpet1) 4 |
http://rosettacode.org/wiki/Shoelace_formula_for_polygonal_area | Shoelace formula for polygonal area | Given the n + 1 vertices x[0], y[0] .. x[N], y[N] of a simple polygon described in a clockwise direction, then the polygon's area can be calculated by:
abs( (sum(x[0]*y[1] + ... x[n-1]*y[n]) + x[N]*y[0]) -
(sum(x[1]*y[0] + ... x[n]*y[n-1]) + x[0]*y[N])
) / 2
(Where abs returns the absolute value)
Task
Write ... | #F.C5.8Drmul.C3.A6 | Fōrmulæ | package main
import "fmt"
type point struct{ x, y float64 }
func shoelace(pts []point) float64 {
sum := 0.
p0 := pts[len(pts)-1]
for _, p1 := range pts {
sum += p0.y*p1.x - p0.x*p1.y
p0 = p1
}
return sum / 2
}
func main() {
fmt.Println(shoelace([]point{{3, 4}, {5, 11}, {1... |
http://rosettacode.org/wiki/Shoelace_formula_for_polygonal_area | Shoelace formula for polygonal area | Given the n + 1 vertices x[0], y[0] .. x[N], y[N] of a simple polygon described in a clockwise direction, then the polygon's area can be calculated by:
abs( (sum(x[0]*y[1] + ... x[n-1]*y[n]) + x[N]*y[0]) -
(sum(x[1]*y[0] + ... x[n]*y[n-1]) + x[0]*y[N])
) / 2
(Where abs returns the absolute value)
Task
Write ... | #Go | Go | package main
import "fmt"
type point struct{ x, y float64 }
func shoelace(pts []point) float64 {
sum := 0.
p0 := pts[len(pts)-1]
for _, p1 := range pts {
sum += p0.y*p1.x - p0.x*p1.y
p0 = p1
}
return sum / 2
}
func main() {
fmt.Println(shoelace([]point{{3, 4}, {5, 11}, {1... |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Delphi | Delphi | echo program Prog;begin writeln('Hi');end. >> "./a.dpt" & dcc32 -Q -CC -W- "./a.dpt" & a.exe |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #E | E | rune --src.e 'println("Hello")' |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Elixir | Elixir | $ elixir -e "IO.puts 'Hello, World!'"
Hello, World! |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Emacs_Lisp | Emacs Lisp | emacs -batch -eval '(princ "Hello World!\n")' |
http://rosettacode.org/wiki/Short-circuit_evaluation | Short-circuit evaluation | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Assume functions a and b return boolean values, and further, the execution of function b takes considerable resources without side effects, an... | #ALGOL_68 | ALGOL 68 | PRIO ORELSE = 2, ANDTHEN = 3; # user defined operators #
OP ORELSE = (BOOL a, PROC BOOL b)BOOL: ( a | a | b ),
ANDTHEN = (BOOL a, PROC BOOL b)BOOL: ( a | b | a );
# user defined Short-circuit_evaluation procedures #
PROC or else = (BOOL a, PROC BOOL b)BOOL: ( a | a | b ),
and then = (BOOL a, PROC BOOL b)BOO... |
http://rosettacode.org/wiki/Show_ASCII_table | Show ASCII table | Task
Show the ASCII character set from values 32 to 127 (decimal) in a table format.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioin... | #ALGOL_68 | ALGOL 68 | BEGIN
# generate an ascii table for characters 32 - 127 #
INT char count := 1;
FOR c FROM 32 TO 127 DO
print( ( whole( c, -4 )
, ": "
, IF c = 32 THEN "SPC"
ELIF c = 127 THEN "DEL"
ELSE " " + REPR c + " "
FI
... |
http://rosettacode.org/wiki/Simple_database | Simple database | Task
Write a simple tool to track a small set of data.
The tool should have a command-line interface to enter at least two different values.
The entered data should be stored in a structured format and saved to disk.
It does not matter what kind of data is being tracked. It could be a collection (CDs, coins, base... | #PowerShell | PowerShell |
function db
{
[CmdletBinding(DefaultParameterSetName="None")]
[OutputType([PSCustomObject])]
Param
(
[Parameter(Mandatory=$false,
Position=0,
ParameterSetName="Add a new entry")]
[string]
$Path = ".\SimpleDatabase.csv",
[Parameter... |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Ruby | Ruby | irb(main):001:0> Time.at(0).utc
=> 1970-01-01 00:00:00 UTC |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Run_BASIC | Run BASIC | eDate$ = date$("01/01/0001")
cDate$ = date$(0) ' 01/01/1901
sDate$ = date$("01/01/1970") |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Rust | Rust | extern crate time;
use time::{at_utc, Timespec};
fn main() {
let epoch = at_utc(Timespec::new(0, 0));
println!("{}", epoch.asctime());
} |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Scala | Scala | import java.util.{Date, TimeZone, Locale}
import java.text.DateFormat
val df=DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.ENGLISH)
df.setTimeZone(TimeZone.getTimeZone("UTC"))
println(df.format(new Date(0))) |
http://rosettacode.org/wiki/Sierpinski_triangle | Sierpinski triangle | Task
Produce an ASCII representation of a Sierpinski triangle of order N.
Example
The Sierpinski triangle of order 4 should look like this:
*
* *
* *
* * * *
* *
* * * *
... | #Forth | Forth | : stars ( mask -- )
begin
dup 1 and if [char] * else bl then emit
1 rshift dup
while space repeat drop ;
: triangle ( order -- )
1 swap lshift ( 2^order )
1 over 0 do
cr over i - spaces dup stars
dup 2* xor
loop 2drop ;
5 triangle |
http://rosettacode.org/wiki/Sierpinski_carpet | Sierpinski carpet | Task
Produce a graphical or ASCII-art representation of a Sierpinski carpet of order N.
For example, the Sierpinski carpet of order 3 should look like this:
###########################
# ## ## ## ## ## ## ## ## #
###########################
### ###### ###### ###
# # # ## # # ## # # #
### ###### ... | #Brainf.2A.2A.2A | Brainf*** | input order and print the associated Sierpinski carpet
orders over 5 require larger cell sizes
+++>>+[[-]>[-],[+[-----------[>[-]++++++[<------>-]<--<<[->>++++++++++<<]>>[-<<+
>>]<+>]]]<]<<[>>+<<-]+>[>>[-]>[-]<<<<[>>>>+<<<<-]>>>>[<<[<<+>>>+<-]>[<+>-]>-]<<<
-]>[-]<<[>+>+<<-]>>[<<+>>-]<[<[>>+>+<<<-]>>>[<<<+>>>-]<[<[>>+... |
http://rosettacode.org/wiki/Shoelace_formula_for_polygonal_area | Shoelace formula for polygonal area | Given the n + 1 vertices x[0], y[0] .. x[N], y[N] of a simple polygon described in a clockwise direction, then the polygon's area can be calculated by:
abs( (sum(x[0]*y[1] + ... x[n-1]*y[n]) + x[N]*y[0]) -
(sum(x[1]*y[0] + ... x[n]*y[n-1]) + x[0]*y[N])
) / 2
(Where abs returns the absolute value)
Task
Write ... | #Haskell | Haskell | import Data.Bifunctor (bimap)
----------- SHOELACE FORMULA FOR POLYGONAL AREA ----------
-- The area of a polygon formed by
-- the list of (x, y) coordinates.
shoelace :: [(Double, Double)] -> Double
shoelace =
let calcSums ((x, y), (a, b)) = bimap (x * b +) (a * y +)
in (/ 2)
. abs
. uncurry... |
http://rosettacode.org/wiki/Shoelace_formula_for_polygonal_area | Shoelace formula for polygonal area | Given the n + 1 vertices x[0], y[0] .. x[N], y[N] of a simple polygon described in a clockwise direction, then the polygon's area can be calculated by:
abs( (sum(x[0]*y[1] + ... x[n-1]*y[n]) + x[N]*y[0]) -
(sum(x[1]*y[0] + ... x[n]*y[n-1]) + x[0]*y[N])
) / 2
(Where abs returns the absolute value)
Task
Write ... | #J | J | shoelace=:verb define
0.5*|+/((* 1&|.)/ - (* _1&|.)/)|:y
) |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Erlang | Erlang | $ erl -noshell -eval 'io:format("hello~n").' -s erlang halt
hello |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #F.23 | F# | > echo printfn "Hello from F#" | fsi --quiet
Hello from F# |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Factor | Factor | $ factor -run=none -e="USE: io \"hi\" print" |
http://rosettacode.org/wiki/Short-circuit_evaluation | Short-circuit evaluation | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Assume functions a and b return boolean values, and further, the execution of function b takes considerable resources without side effects, an... | #ALGOL_W | ALGOL W | begin
logical procedure a( logical value v ) ; begin write( "a: ", v ); v end ;
logical procedure b( logical value v ) ; begin write( "b: ", v ); v end ;
write( "and: ", a( true ) and b( true ) );
write( "---" );
write( "or: ", a( true ) or b( true ) );
write( "---" );
write( "and: "... |
http://rosettacode.org/wiki/Short-circuit_evaluation | Short-circuit evaluation | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Assume functions a and b return boolean values, and further, the execution of function b takes considerable resources without side effects, an... | #AppleScript | AppleScript | on run
map(test, {|and|, |or|})
end run
-- test :: ((Bool, Bool) -> Bool) -> (Bool, Bool, Bool, Bool)
on test(f)
map(f, {{true, true}, {true, false}, {false, true}, {false, false}})
end test
-- |and| :: (Bool, Bool) -> Bool
on |and|(tuple)
set {x, y} to tuple
a(x) and b(y)
end |and|
-- |... |
http://rosettacode.org/wiki/Show_ASCII_table | Show ASCII table | Task
Show the ASCII character set from values 32 to 127 (decimal) in a table format.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioin... | #ALGOL_W | ALGOL W | begin
% generate an ascii table for chars 32 - 127 %
integer cPos;
cPos := 0;
for i := 32 until 127 do begin
if cPos = 0 then write();
cPos := ( cPos + 1 ) rem 6;
writeon( i_w := 3, s_w := 0, i, ": " );
if i = 32 then writeon( "Spc ")
else if i = ... |
http://rosettacode.org/wiki/Simple_database | Simple database | Task
Write a simple tool to track a small set of data.
The tool should have a command-line interface to enter at least two different values.
The entered data should be stored in a structured format and saved to disk.
It does not matter what kind of data is being tracked. It could be a collection (CDs, coins, base... | #Python | Python | #!/usr/bin/python3
'''\
Simple database for: http://rosettacode.org/wiki/Simple_database
'''
import argparse
from argparse import Namespace
import datetime
import shlex
def parse_args():
'Set up, parse, and return arguments'
parser = argparse.ArgumentParser(epilog=globals()['__doc__'])
parser.... |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Scheme | Scheme | ; Display date at Time Zero in UTC.
(printf "~s~%" (time-utc->date (make-time 'time-utc 0 0) 0)) |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Seed7 | Seed7 | $ include "seed7_05.s7i";
include "time.s7i";
const proc: main is func
begin
writeln(time.value);
end func; |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Sidef | Sidef | say Time.new(0).gmtime.ctime; |
http://rosettacode.org/wiki/Sierpinski_triangle | Sierpinski triangle | Task
Produce an ASCII representation of a Sierpinski triangle of order N.
Example
The Sierpinski triangle of order 4 should look like this:
*
* *
* *
* * * *
* *
* * * *
... | #Fortran | Fortran | program Sierpinski_triangle
implicit none
call Triangle(4)
contains
subroutine Triangle(n)
implicit none
integer, parameter :: i64 = selected_int_kind(18)
integer, intent(in) :: n
integer :: i, k
integer(i64) :: c
do i = 0, n*4-1
c = 1
write(*, "(a)", advance="no") repeat(" ", 2 * (n*4 -... |
http://rosettacode.org/wiki/Sierpinski_carpet | Sierpinski carpet | Task
Produce a graphical or ASCII-art representation of a Sierpinski carpet of order N.
For example, the Sierpinski carpet of order 3 should look like this:
###########################
# ## ## ## ## ## ## ## ## #
###########################
### ###### ###### ###
# # # ## # # ## # # #
### ###### ... | #C | C | #include <stdio.h>
int main()
{
int i, j, dim, d;
int depth = 3;
for (i = 0, dim = 1; i < depth; i++, dim *= 3);
for (i = 0; i < dim; i++) {
for (j = 0; j < dim; j++) {
for (d = dim / 3; d; d /= 3)
if ((i % (d * 3)) / d == 1 && (j % (d * 3)) / d == 1)
break;
printf(d ? " " : "##");
}
pri... |
http://rosettacode.org/wiki/Shoelace_formula_for_polygonal_area | Shoelace formula for polygonal area | Given the n + 1 vertices x[0], y[0] .. x[N], y[N] of a simple polygon described in a clockwise direction, then the polygon's area can be calculated by:
abs( (sum(x[0]*y[1] + ... x[n-1]*y[n]) + x[N]*y[0]) -
(sum(x[1]*y[0] + ... x[n]*y[n-1]) + x[0]*y[N])
) / 2
(Where abs returns the absolute value)
Task
Write ... | #Java | Java | import java.util.List;
public class ShoelaceFormula {
private static class Point {
int x, y;
Point(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public String toString() {
return String.format("(%d, %d)", x, y);
}
}
... |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Forth | Forth | $ gforth -e ".( Hello) cr bye"
Hello |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Fortran | Fortran |
$ gawk 'BEGIN{print"write(6,\"(2(g12.3,x))\")(i/10.0,besj1(i/10.0), i=0,1000)\nend";exit(0)}'|gfortran -ffree-form -x f95 - | gnuplot -p -e 'plot "<./a.out" t "Bessel function of 1st kind" w l'
|
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Free_Pascal | Free Pascal | echo "begin writeLn('Hi'); end." | ifpc /dev/stdin |
http://rosettacode.org/wiki/Short-circuit_evaluation | Short-circuit evaluation | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Assume functions a and b return boolean values, and further, the execution of function b takes considerable resources without side effects, an... | #AutoHotkey | AutoHotkey | i = 1
j = 1
x := a(i) and b(j)
y := a(i) or b(j)
a(p)
{
MsgBox, a() was called with the parameter "%p%".
Return, p
}
b(p)
{
MsgBox, b() was called with the parameter "%p%".
Return, p
} |
http://rosettacode.org/wiki/Short-circuit_evaluation | Short-circuit evaluation | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Assume functions a and b return boolean values, and further, the execution of function b takes considerable resources without side effects, an... | #AWK | AWK | #!/usr/bin/awk -f
BEGIN {
print (a(1) && b(1))
print (a(1) || b(1))
print (a(0) && b(1))
print (a(0) || b(1))
}
function a(x) {
print " x:"x
return x
}
function b(y) {
print " y:"y
return y
} |
http://rosettacode.org/wiki/Show_ASCII_table | Show ASCII table | Task
Show the ASCII character set from values 32 to 127 (decimal) in a table format.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioin... | #APL | APL | {(¯3↑⍕⍵),': ',∊('Spc' 'Del'(⎕UCS ⍵))[32 127⍳⍵]}¨⍉6 16⍴31+⍳96 |
http://rosettacode.org/wiki/Simple_database | Simple database | Task
Write a simple tool to track a small set of data.
The tool should have a command-line interface to enter at least two different values.
The entered data should be stored in a structured format and saved to disk.
It does not matter what kind of data is being tracked. It could be a collection (CDs, coins, base... | #Racket | Racket |
#!/usr/bin/env racket
#lang racket
(define (*write file data) ; write data in human readable format (sexpr/line)
(with-output-to-file file #:exists 'replace
(lambda () (for ([x data]) (printf "~s\n" x)))))
(define *read file->list) ; read our "human readable format"
(command-line
#:once-any
[("-a") file t... |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Standard_ML | Standard ML | - Date.toString (Date.fromTimeUniv Time.zeroTime);
val it = "Thu Jan 1 00:00:00 1970" : string |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Stata | Stata | . di %td 0
01jan1960
. di %tc 0
01jan1960 00:00:00 |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Tcl | Tcl | % clock format 0 -gmt 1
Thu Jan 01 00:00:00 GMT 1970 |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #TUSCRIPT | TUSCRIPT | $$ MODE TUSCRIPT
- epoch
number=1
dayofweeknr=DATE (date,day,month,year,number)
epoch=JOIN(year,"-",month,day)
PRINT "epoch: ", epoch," (daynumber ",number,")"
- today's daynumber
dayofweeknr=DATE (today,day,month,year,number)
date=JOIN (year,"-",month,day)
PRINT "today's date: ", date," (daynumber ", number,")" |
http://rosettacode.org/wiki/Sierpinski_triangle | Sierpinski triangle | Task
Produce an ASCII representation of a Sierpinski triangle of order N.
Example
The Sierpinski triangle of order 4 should look like this:
*
* *
* *
* * * *
* *
* * * *
... | #GAP | GAP | # Using parity of binomial coefficients
SierpinskiTriangle := function(n)
local i, j, s, b;
n := 2^n - 1;
b := " ";
while Size(b) < n do
b := Concatenation(b, b);
od;
for i in [0 .. n] do
s := "";
for j in [0 .. i] do
if IsEvenInt(Binomial(i, j)) then
Append(s, " ");
else
Append(s, "* ");
... |
http://rosettacode.org/wiki/Sierpinski_carpet | Sierpinski carpet | Task
Produce a graphical or ASCII-art representation of a Sierpinski carpet of order N.
For example, the Sierpinski carpet of order 3 should look like this:
###########################
# ## ## ## ## ## ## ## ## #
###########################
### ###### ###### ###
# # # ## # # ## # # #
### ###### ... | #C.23 | C# | using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static List<string> NextCarpet(List<string> carpet)
{
return carpet.Select(x => x + x + x)
.Concat(carpet.Select(x => x + x.Replace('#', ' ') + x))
.Concat(carpet.Select(x => x ... |
http://rosettacode.org/wiki/Shoelace_formula_for_polygonal_area | Shoelace formula for polygonal area | Given the n + 1 vertices x[0], y[0] .. x[N], y[N] of a simple polygon described in a clockwise direction, then the polygon's area can be calculated by:
abs( (sum(x[0]*y[1] + ... x[n-1]*y[n]) + x[N]*y[0]) -
(sum(x[1]*y[0] + ... x[n]*y[n-1]) + x[0]*y[N])
) / 2
(Where abs returns the absolute value)
Task
Write ... | #JavaScript | JavaScript | (() => {
"use strict";
// ------- SHOELACE FORMULA FOR POLYGONAL AREA -------
// shoelaceArea :: [(Float, Float)] -> Float
const shoeLaceArea = vertices => abs(
uncurry(subtract)(
ap(zip)(compose(tail, cycle))(
vertices
)
.reduce(
... |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #FreeBASIC | FreeBASIC | ' FB 1.05.0 Win64
Shell "echo For i As Integer = 1 To 10 : Print i : Next > zzz.bas && fbc zzz.bas && zzz"
Sleep |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #Frink | Frink | $ frink -e "factorFlat[2^67-1]" |
http://rosettacode.org/wiki/Shell_one-liner | Shell one-liner | Task
Show how to specify and execute a short program in the language from a command shell, where the input to the command shell is only one line in length.
Avoid depending on the particular shell or operating system used as much as is reasonable; if the language has notable implementations which have different comman... | #FutureBasic | FutureBasic |
window 1,,(0,0,160,120):Str255 a:open "Unix",1,"cal 10 2018":do:line input #1,a:print a:until eof(1):close 1:HandleEvents
|
http://rosettacode.org/wiki/Short-circuit_evaluation | Short-circuit evaluation | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Assume functions a and b return boolean values, and further, the execution of function b takes considerable resources without side effects, an... | #Axe | Axe | TEST(0,0)
TEST(0,1)
TEST(1,0)
TEST(1,1)
Return
Lbl TEST
r₁→X
r₂→Y
Disp X▶Hex+3," and ",Y▶Hex+3," = ",(A(X)?B(Y))▶Hex+3,i
Disp X▶Hex+3," or ",Y▶Hex+3," = ",(A(X)??B(Y))▶Hex+3,i
.Wait for keypress
getKeyʳ
Return
Lbl A
r₁
Return
Lbl B
r₁
Return |
http://rosettacode.org/wiki/Short-circuit_evaluation | Short-circuit evaluation | Control Structures
These are examples of control structures. You may also be interested in:
Conditional structures
Exceptions
Flow-control structures
Loops
Assume functions a and b return boolean values, and further, the execution of function b takes considerable resources without side effects, an... | #BaCon | BaCon | ' Short-circuit evaluation
FUNCTION a(f)
PRINT "FUNCTION a"
RETURN f
END FUNCTION
FUNCTION b(f)
PRINT "FUNCTION b"
RETURN f
END FUNCTION
PRINT "FALSE and TRUE"
x = a(FALSE) AND b(TRUE)
PRINT x
PRINT "TRUE and TRUE"
x = a(TRUE) AND b(TRUE)
PRINT x
PRINT "FALSE or FALSE"
y = a(FALSE) OR b(FALSE)
P... |
http://rosettacode.org/wiki/Show_ASCII_table | Show ASCII table | Task
Show the ASCII character set from values 32 to 127 (decimal) in a table format.
Other tasks related to string operations:
Metrics
Array length
String length
Copy a string
Empty string (assignment)
Counting
Word frequency
Letter frequency
Jewels and stones
I before E except after C
Bioin... | #AppleScript | AppleScript | -- asciiTable :: () -> String
on asciiTable()
script row
on |λ|(x)
concat(map(justifyLeft(12, space), x))
end |λ|
end script
unlines(map(row, ¬
transpose(chunksOf(16, map(my asciiEntry, ¬
enumFromTo(32, 127))))))
end asciiTable
--------------------------... |
http://rosettacode.org/wiki/Simple_database | Simple database | Task
Write a simple tool to track a small set of data.
The tool should have a command-line interface to enter at least two different values.
The entered data should be stored in a structured format and saved to disk.
It does not matter what kind of data is being tracked. It could be a collection (CDs, coins, base... | #Raku | Raku | #!/usr/bin/env raku
use JSON::Fast ;
sub MAIN( :$server='0.0.0.0', :$port=3333, :$dbfile='db' ) {
my %db;
my %index;
my $dbdata = slurp "$dbfile.json" ;
my $indexdata = slurp "{$dbfile}_index.json" ;
%db = from-json($dbdata) if $dbdata ;
%index = from-json($indexdata) if $indexdata ;
react {
... |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #UNIX_Shell | UNIX Shell | $ date -ur 0
Thu Jan 1 00:00:00 UTC 1970 |
http://rosettacode.org/wiki/Show_the_epoch | Show the epoch | Task
Choose popular date libraries used by your language and show the epoch those libraries use.
A demonstration is preferable (e.g. setting the internal representation of the date to 0 ms/ns/etc., or another way that will still show the epoch even if it is changed behind the scenes by the implementers), b... | #Visual_Basic | Visual Basic | Sub Main()
Debug.Print Format(0, "dd mmm yyyy hh:mm")
End Sub |
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.