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/Sierpinski_arrowhead_curve
Sierpinski arrowhead curve
Task Produce a graphical or ASCII-art representation of a  Sierpinski arrowhead curve  of at least order  3.
#REXX
REXX
/*REXX pgm computes and displays a Sierpinski Arrowhead Curve using the characters: \_/ */ parse arg order . /*obtain optional argument from the CL.*/ if order=='' | order=="," then order= 5 /*Not specified? Then use the default.*/ say ' Sierpinski arrowhead curve of order' o...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Seed7
Seed7
$ include "seed7_05.s7i"; include "duration.s7i";   const proc: main is func local var integer: secondsToSleep is 0; begin write("Enter number of seconds to sleep: "); readln(secondsToSleep); writeln("Sleeping..."); wait(secondsToSleep . SECONDS); writeln("Awake!"); end func;
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#SenseTalk
SenseTalk
  ask "How long would you like to sleep?" message "Your answer may include any duration, such as 5 seconds, 2 hours, or even 3 centuries!" get the value of it   if it is a duration then put it into sleepyTime else answer "Sorry, that wasn't a valid duration!" exit all end if   put "Sleeping for " & sleepyTime & "......
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Prolog
Prolog
:- dynamic click/1.   dialog('Simple windowed application', [ object := Simple_windowed_application, parts := [ Simple_windowed_application := dialog('Simple windowed application'), Name := label(name, 'There have been no clicks yet'), Bt...
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#Action.21
Action!
PROC Main() INT ARRAY xs=[249 200 96 80 175] BYTE ARRAY ys=[82 176 159 55 7] INT x,y BYTE i,CH=$02FC,COLOR1=$02C5,COLOR2=$02C6   Graphics(8+16) Color=1 COLOR1=$0C COLOR2=$02   x=160+Rand(30) y=96+Rand(30) DO i=Rand(5) x=x+(xs(i)-x)*62/100 y=y+(ys(i)-y)*62/100 Plot(x,y) UNTIL CH#$FF ...
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: * * * * * * * * * * * * * * * ...
#Arturo
Arturo
sierpinski: function [order][ s: shl 1 order loop (s-1)..0 'y [ do.times: y -> prints " " loop 0..dec s-y 'x [ if? zero? and x y -> prints "* " else -> prints " " ] print "" ] ]   sierpinski 4
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#C.2B.2B
C++
  #include <windows.h> #include <string> #include <iostream>   const int BMP_SIZE = 612;   class myBitmap { public: myBitmap() : pen( NULL ), brush( NULL ), clr( 0 ), wid( 1 ) {} ~myBitmap() { DeleteObject( pen ); DeleteObject( brush ); DeleteDC( hdc ); DeleteObject( bmp ); } bool create...
http://rosettacode.org/wiki/Sierpinski_arrowhead_curve
Sierpinski arrowhead curve
Task Produce a graphical or ASCII-art representation of a  Sierpinski arrowhead curve  of at least order  3.
#Ruby
Ruby
  load_libraries :grammar attr_reader :points   def setup sketch_title 'Sierpinski Arrowhead' sierpinski = SierpinskiArrowhead.new(Vec2D.new(width * 0.15, height * 0.7)) production = sierpinski.generate 6 # 6 generations looks OK @points = sierpinski.translate_rules(production) no_loop end   def draw backgr...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Sidef
Sidef
var sec = read(Number); # any positive number (it may be fractional) say "Sleeping..."; Sys.sleep(sec); # in seconds #Sys.usleep(sec); # in microseconds #Sys.nanosleep(sec); # in nanoseconds say "Awake!";
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Smalltalk
Smalltalk
t := (FillInTheBlankMorph request: 'Enter time in seconds') asNumber. Transcript show: 'Sleeping...'. (Delay forSeconds: t) wait. Transcript show: 'Awake!'.  
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#PureBasic
PureBasic
Define window_0 Define window_0_Text_0, window_0_Button_1 Define clicks, txt$, flags   flags = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered window_0 = OpenWindow(#PB_Any, 408, 104, 280, 45, "Simple windowed application", flags) If window_0 SmartWindowRefresh(window_0, #True) window_0_Te...
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#AutoHotkey
AutoHotkey
W := H := 640 hw := W / 2 margin := 20 radius := hw - 2 * margin side := radius * Sin(PI := 3.141592653589793 / 5) * 2 order := 5   gdip1() drawPentagon(hw, 3*margin, side, order, 1) return   drawPentagon(x, y, side, depth, colorIndex){ global G, hwnd1, hdc, Width, Height Red := "0xFFFF0000" Gree...
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: * * * * * * * * * * * * * * * ...
#ATS
ATS
  (* ****** ****** *) // // How to compile: // // patscc -DATS_MEMALLOC_LIBC -o sierpinski sierpinski.dats // (* ****** ****** *) // #include "share/atspre_staload.hats" // (* ****** ****** *)   #define SIZE 16   implement main0 () = { // var x: int // val () = for (x := SIZE-1; x >= 0; x := x-1) { var i: int val (...
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#D
D
void main() { import grayscale_image;   enum order = 8, margin = 10, width = 2 ^^ order;   auto im = new Image!Gray(width + 2 * margin, width + 2 * margin); im.clear(Gray.white);   foreach (immutable y; 0 .. width) foreach (immutable x; 0 .. width) if ((x & y) =...
http://rosettacode.org/wiki/Sierpinski_arrowhead_curve
Sierpinski arrowhead curve
Task Produce a graphical or ASCII-art representation of a  Sierpinski arrowhead curve  of at least order  3.
#Rust
Rust
// [dependencies] // svg = "0.8.0"   const SQRT3_2: f64 = 0.86602540378444;   use svg::node::element::path::Data;   struct Cursor { x: f64, y: f64, angle: i32, }   impl Cursor { fn new(x: f64, y: f64) -> Cursor { Cursor { x: x, y: y, angle: 0, } } ...
http://rosettacode.org/wiki/Sierpinski_arrowhead_curve
Sierpinski arrowhead curve
Task Produce a graphical or ASCII-art representation of a  Sierpinski arrowhead curve  of at least order  3.
#Sidef
Sidef
var rules = Hash( x => 'yF+xF+y', y => 'xF-yF-x', )   var lsys = LSystem( width: 550, height: 500,   xoff: -20, yoff: -30,   len: 4, turn: -90, angle: 60, color: 'dark green', )   lsys.execute('xF', 7, "sierpiński_arrowhead.png", rules)
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Standard_ML
Standard ML
(TextIO.print "input a number of seconds please: "; let val seconds = valOf (Int.fromString (valOf (TextIO.inputLine TextIO.stdIn))) in TextIO.print "Sleeping...\n"; OS.Process.sleep (Time.fromReal seconds); (* it takes a Time.time data structure as arg, but in my imp...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Stata
Stata
program sleep_awake * pass duration in milliseconds display "Sleeping..." sleep `0' display "Awake!" end   sleep_awake 2000
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Python
Python
from functools import partial import tkinter as tk   def on_click(label: tk.Label, counter: tk.IntVar) -> None: counter.set(counter.get() + 1) label["text"] = f"Number of clicks: {counter.get()}"   def main(): window = tk.Tk() window.geometry("200x50+100+100") label = tk.Label(master=wi...
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#C
C
  #include<graphics.h> #include<stdlib.h> #include<stdio.h> #include<math.h> #include<time.h>   #define pi M_PI   int main(){   time_t t; double side, **vertices,seedX,seedY,windowSide = 500,sumX=0,sumY=0; int i,iter,choice,numSides;   printf("Enter number of sides : "); scanf("%d",&numSides);   printf("Enter pol...
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: * * * * * * * * * * * * * * * ...
#AutoHotkey
AutoHotkey
Loop 6 MsgBox % Triangle(A_Index)   Triangle(n,x=0,y=1) { ; Triangle(n) -> string of dots and spaces of Sierpinski triangle Static t, l ; put chars in a static string If (x < 1) { ; when called with one parameter l := 2*x := 1<<(n-1) ...
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#Erlang
Erlang
  -module(sierpinski). -author("zduchac"). -export([start/0]).   sierpinski(DC, Order) -> Size = 1 bsl Order, sierpinski(DC, Order, Size, 0, 0).   sierpinski(_, _, Size, _, Y) when Y =:= Size -> ok; sierpinski(DC, Order, Size, X, Y) when X =:= Size -> sierpinski(DC, Order, Size, 0, Y + 1); sierpinski(DC...
http://rosettacode.org/wiki/Sierpinski_arrowhead_curve
Sierpinski arrowhead curve
Task Produce a graphical or ASCII-art representation of a  Sierpinski arrowhead curve  of at least order  3.
#Wren
Wren
import "graphics" for Canvas, Color, Point import "dome" for Window   class Game { static init() { Window.title = "Sierpinski Arrowhead Curve" __width = 770 __height = 770 Window.resize(__width, __height) Canvas.resize(__width, __height) var order = 6 __iy = (...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Suneido
Suneido
function (time) { Print("Sleeping...") Sleep(time) // time is in milliseconds Print("Awake!") }
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Swift
Swift
import Foundation   println("Enter number of seconds to sleep") let input = NSFileHandle.fileHandleWithStandardInput() var amount = NSString(data:input.availableData, encoding: NSUTF8StringEncoding)?.intValue var interval = NSTimeInterval(amount!) println("Sleeping...") NSThread.sleepForTimeInterval(interval)   println...
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#R
R
library(gWidgets) library(gWidgetstcltk) win <- gwindow() lab <- glabel("There have been no clicks yet", container=win) btn <- gbutton("click me", container=win, handle=function(h, ...) { val <- as.numeric(svalue(lab)) svalue(lab) <- ifelse(is.na(val) ,"1", as.character(val + 1)) } )
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Racket
Racket
  #lang racket/gui   (define frame (new frame% [label "There have been no clicks yet"]))   (define num-clicks 0) (define (cb obj me) (set! num-clicks (add1 num-clicks)) (send frame set-label (format "~a" num-clicks)))   (new button% [parent frame] [label "Click me"] [callback cb]) (send frame show #t)  
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#C.2B.2B
C++
#include <iomanip> #include <iostream>   #define _USE_MATH_DEFINES #include <math.h>   constexpr double degrees(double deg) { const double tau = 2.0 * M_PI; return deg * tau / 360.0; }   const double part_ratio = 2.0 * cos(degrees(72)); const double side_ratio = 1.0 / (part_ratio + 2.0);   /// Define a position...
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: * * * * * * * * * * * * * * * ...
#APL
APL
A←67⍴0⋄A[34]←1⋄' #'[1+32 67⍴{~⊃⍵:⍵,∇(1⌽⍵)≠¯1⌽⍵⋄⍬}A]
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#ERRE
ERRE
  PROGRAM SIERPINSKY   !$INCLUDE="PC.LIB"   BEGIN ORDER%=8 SIZE%=2^ORDER% SCREEN(9) GR_WINDOW(0,0,520,520) FOR Y%=0 TO SIZE%-1 DO FOR X%=0 TO SIZE%-1 DO IF (X% AND Y%)=0 THEN PSET(X%*2,Y%*2,2) END IF END FOR END FOR GET(K$) END PROGRAM  
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#Factor
Factor
USING: accessors images images.loader kernel literals math math.bits math.functions make sequences ; IN: rosetta-code.sierpinski-triangle-graphical   CONSTANT: black B{ 33 33 33 255 } CONSTANT: white B{ 255 255 255 255 } CONSTANT: size $[ 2 8 ^ ]  ! edit 8 to change order   ! Generate Sierpinksi's triangle...
http://rosettacode.org/wiki/Sierpinski_arrowhead_curve
Sierpinski arrowhead curve
Task Produce a graphical or ASCII-art representation of a  Sierpinski arrowhead curve  of at least order  3.
#XPL0
XPL0
int PosX, PosY; real Dir;   proc Curve(Order, Length, Angle); int Order; real Length, Angle; [if Order = 0 then [PosX:= PosX + fix(Length*Cos(Dir)); PosY:= PosY - fix(Length*Sin(Dir)); Line(PosX, PosY, $E \yellow\); ] else [Curve(Order-1, Length/2.0, -Angle); Dir:= Dir + ...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Tcl
Tcl
puts -nonewline "Enter a number of milliseconds to sleep: " flush stdout set millis [gets stdin] puts Sleeping... after $millis puts Awake!
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#TI-89_BASIC
TI-89 BASIC
Local dur_secs,st0,st,seconds Define seconds() = Func Local hms getTime()→hms Return ((hms[1] * 60 + hms[2]) * 60) + hms[3] EndFunc ClockOn Prompt dur_secs Disp "Sleeping..." seconds()→st st→st0 While when(st<st0, st+86400, st) - st0 < dur_secs seconds()→st EndWhile Disp "Awake!"
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Raku
Raku
use GTK::Simple; use GTK::Simple::App;   my GTK::Simple::App $app .= new(title => 'Simple Windowed Application');   $app.size-request(350, 100);   $app.set-content( GTK::Simple::VBox.new( my $label = GTK::Simple::Label.new( text => 'There have been no clicks yet'), my $button = GTK::Simple::Button...
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#D
D
import std.math; import std.stdio;   /// Convert degrees into radians, as that is the accepted unit for sin/cos etc... real degrees(real deg) { immutable tau = 2.0 * PI; return deg * tau / 360.0; }   immutable part_ratio = 2.0 * cos(72.degrees); immutable side_ratio = 1.0 / (part_ratio + 2.0);   /// Use the pro...
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: * * * * * * * * * * * * * * * ...
#AWK
AWK
# WST.AWK - Waclaw Sierpinski's triangle contributed by Dan Nielsen # syntax: GAWK -f WST.AWK [-v X=anychar] iterations # example: GAWK -f WST.AWK -v X=* 2 BEGIN { n = ARGV[1] + 0 # iterations if (n !~ /^[0-9]+$/) { exit(1) } if (n == 0) { width = 3 } row = split("X,X X,X X,X X X X",A,",") # seed the ...
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#Forth
Forth
include lib/graphics.4th \ graphics support is needed   520 pic_width ! \ width of the image 520 pic_height ! \ height of the image   9 constant order \ Sierpinski's triangle order   black 255 whiteout \ black ink, whit...
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#gnuplot
gnuplot
# triangle_x(n) and triangle_y(n) return X,Y coordinates for the # Sierpinski triangle point number n, for integer n. triangle_x(n) = (n > 0 ? 2*triangle_x(int(n/3)) + digit_to_x(int(n)%3) : 0) triangle_y(n) = (n > 0 ? 2*triangle_y(int(n/3)) + digit_to_y(int(n)%3) : 0) digit_to_x(d) = (d==0 ? 0 : d==1 ? -1 : 1) digit_t...
http://rosettacode.org/wiki/Sierpinski_arrowhead_curve
Sierpinski arrowhead curve
Task Produce a graphical or ASCII-art representation of a  Sierpinski arrowhead curve  of at least order  3.
#zkl
zkl
order:=7; sierpinskiArrowheadCurve(order) : turtle(_,order);   fcn sierpinskiArrowheadCurve(n){ // Lindenmayer system --> Data of As & Bs var [const] A="BF+AF+B", B="AF-BF-A"; // Production rules var [const] Axiom="AF"; buf1,buf2 := Data(Void,Axiom).howza(3), Data().howza(3); // characters do(n){ ...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Toka
Toka
1 import sleep as sleep() [ ." Sleeping...\n" sleep() drop ." Awake!\n" bye ] is sleep 45 sleep
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#TUSCRIPT
TUSCRIPT
  $$ MODE TUSCRIPT secondsrange=2 PRINT "Sleeping ",secondsrange," seconds " WAIT #secondsrange PRINT "Awake after Naping ",secondsrange, " seconds"  
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#RapidQ
RapidQ
DECLARE SUB buttonClick   CREATE form AS QForm Center Height = 120 Width = 300   CREATE text AS QLabel Caption = "There have been no clicks yet." Left = 30: Top = 20 END CREATE   CREATE button1 AS QButton Caption = "Click me" Left = 100: Top = 50: Height = 25: Wid...
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#REBOL
REBOL
rebol [ Title: "Simple Windowed Application" URL: http://rosettacode.org/wiki/Simple_Windowed_Application ]   clicks: 0   ; Simple GUI's in REBOL can be defined with 'layout', a ; special-purpose language (dialect, in REBOL-speak) for specifying ; interfaces. In the example below, I describe a gradient background ; w...
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#Go
Go
package main   import ( "github.com/fogleman/gg" "image/color" "math" )   var ( red = color.RGBA{255, 0, 0, 255} green = color.RGBA{0, 255, 0, 255} blue = color.RGBA{0, 0, 255, 255} magenta = color.RGBA{255, 0, 255, 255} cyan = color.RGBA{0, 255, 255, 255} )   var ( w, h ...
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: * * * * * * * * * * * * * * * ...
#BASH_.28feat._sed_.26_tr.29
BASH (feat. sed & tr)
  #!/bin/bash   # Basic principle: # # # x -> dxd d -> dd s -> s # xsx dd s # # In the end all 'd' and 's' are removed. # 0x7F800000 function rec(){ if [ $1 == 0 ] then echo "x" else rec $[ $1 - 1 ] | while read line ; do echo "$line" | sed "s/d/dd/g" | se...
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#Go
Go
package main   import ( "fmt" "image" "image/color" "image/draw" "image/png" "os" )   func main() { const order = 8 const width = 1 << order const margin = 10 bounds := image.Rect(-margin, -margin, width+2*margin, width+2*margin) im := image.NewGray(bounds) gBlack := colo...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#TXR
TXR
(let ((usec (progn (put-string "enter sleep usecs: ") (tointz (get-line))))) (put-string "Sleeping ... ") (flush-stream) (usleep usec) (put-line "Awake!"))
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#UNIX_Shell
UNIX Shell
printf "Enter a time in seconds to sleep: " read seconds echo "Sleeping..." sleep "$seconds" echo "Awake!"
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Red
Red
Red[]   clicks: 0   view [ t: text "There have been no clicks yet" return button "click me" [ clicks: clicks + 1 t/data: rejoin ["clicks: " clicks] ] ]
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#Haskell
Haskell
import Graphics.Gloss   pentaflake :: Int -> Picture pentaflake order = iterate transformation pentagon !! order where transformation = Scale s s . foldMap copy [0,72..288] copy a = Rotate a . Translate 0 x pentagon = Polygon [ (sin a, cos a) | a <- [0,2*pi/5..2*pi] ] x = 2*cos(pi/5) s = 1/(1+x) ...
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: * * * * * * * * * * * * * * * ...
#BASIC
BASIC
DECLARE SUB triangle (x AS INTEGER, y AS INTEGER, length AS INTEGER, n AS INTEGER)   CLS triangle 1, 1, 16, 5   SUB triangle (x AS INTEGER, y AS INTEGER, length AS INTEGER, n AS INTEGER) IF n = 0 THEN LOCATE y, x: PRINT "*"; ELSE triangle x, y + length, length / 2, n - 1 triangle x + len...
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#Haskell
Haskell
import Diagrams.Prelude import Diagrams.Backend.Cairo.CmdLine   triangle = eqTriangle # fc black # lw 0   reduce t = t === (t ||| t)   sierpinski = iterate reduce triangle   main = defaultMain $ sierpinski !! 7  
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Ursa
Ursa
out "Sleeping..." endl console # sleep for 5 seconds (5000 milliseconds) sleep 5000 out "Awake!" endl console
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#VBA
VBA
  Function Sleep(iSecsWait As Integer) Debug.Print Now(), "Sleeping..." Application.Wait Now + iSecsWait / 86400 'Time is stored as fractions of 24 hour day Debug.Print Now(), "Awake!" End Function  
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Ring
Ring
  Load "guilib.ring"   MyApp = New qApp { num = 0 win1 = new qWidget() { setwindowtitle("Hello World") setGeometry(100,100,370,250)   btn1 = new qpushbutton(win1) { setGeometry(150,200,100,30) settext("click me") ...
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#Java
Java
import java.awt.*; import java.awt.event.ActionEvent; import java.awt.geom.Path2D; import static java.lang.Math.*; import java.util.Random; import javax.swing.*;   public class SierpinskiPentagon extends JPanel { // exterior angle final double degrees072 = toRadians(72);   /* After scaling we'll have 2 side...
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: * * * * * * * * * * * * * * * ...
#BCPL
BCPL
get "libhdr"   manifest $( SIZE = 1 << 4 $)   let start() be $( for y = SIZE-1 to 0 by -1 do $( for i=1 to y do wrch(' ') for x=0 to SIZE-y-1 do writes((x & y) ~= 0 -> " ", "** ") wrch('*N') $) $)
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#Icon_and_Unicon
Icon and Unicon
link wopen   procedure main(A) local width, margin, x, y   width := 2 ^ (order := (0 < integer(\A[1])) | 8) wsize := width + 2 * (margin := 30 ) WOpen("label=Sierpinski", "size="||wsize||","||wsize) | stop("*** cannot open window")   every y := 0 to width - 1 do every x := 0 to width - 1 do ...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#VBScript
VBScript
  iSeconds=InputBox("Enter a time in seconds to sleep: ","Sleep Example for RosettaCode.org") WScript.Echo "Sleeping..." WScript.Sleep iSeconds*1000 'Sleep is done in Milli-Seconds WScript.Echo "Awake!"  
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Vedit_macro_language
Vedit macro language
#1 = Get_Num("Sleep time in 1/10 seconds: ") Message("Sleeping...\n") Sleep(#1) Message("Awake!\n")
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Ruby
Ruby
require 'tk' str = TkVariable.new("no clicks yet") count = 0 root = TkRoot.new TkLabel.new(root, "textvariable" => str).pack TkButton.new(root) do text "click me" command {str.value = count += 1} pack end Tk.mainloop
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Run_BASIC
Run BASIC
msg$ = "There have been no clicks yet" [loop] cls ' clear screen print msg$ button #c, "Click Me", [clickMe] 'create a button with handle and goto [tag] wait   [clickMe] clicks = clicks + 1 msg$ = "Button has been clicked ";clicks;" times" goto [loop]
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...
#ABAP
ABAP
DATA: lv_date TYPE datum.   lv_date = 0.   WRITE: / lv_date.  
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#JavaScript
JavaScript
  <html> <head> <script type="application/x-javascript"> // Globals var cvs, ctx, scale=500, p0, ord=0, clr='blue', jc=0; var clrs=['blue','navy','green','darkgreen','red','brown','yellow','cyan'];   function p5f() { cvs = document.getElementById("cvsid"); ctx = cvs.getContext("2d"); cvs.onclick=iter; pInit(); ...
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#Julia
Julia
using Printf   const sides = 5 const order = 5 const dim = 250 const scale = (3 - order ^ 0.5) / 2 const τ = 8 * atan(1, 1) const orders = map(x -> ((1 - scale) * dim) * scale ^ x, 0:order-1) cis(x) = Complex(cos(x), sin(x)) const vertices = map(x -> cis(x * τ / sides), 0:sides-1)   fh = open("sierpinski_pentagon.sv...
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: * * * * * * * * * * * * * * * ...
#Befunge
Befunge
41+2>\#*1#2-#<:#\_$:1+v v:$_:#`0#\\#00#:p#->#1< >2/1\0p:2/\::>1-:>#v_1v >8#4*#*+#+,#5^#5g0:< 1 vg11<\*g11!:g 0-1:::<p< >!*+!!\0g11p\ 0p1-:#^_v @$$_\#!:#::#-^#1\$,+55<
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#J
J
load 'viewmat' 'rgb'viewmat--. |. (~:_1&|.)^:(<@#) (2^8){.1  
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#Java
Java
import javax.swing.*; import java.awt.*;   /** * SierpinskyTriangle.java * Draws a SierpinskyTriangle in a JFrame * The order of complexity is given from command line, but * defaults to 3 * * @author Istarnion */   class SierpinskyTriangle {   public static void main(String[] args) { int i = 3; // Default to 3 i...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Visual_Basic_.NET
Visual Basic .NET
Module Program Sub Main() Dim millisecondsSleepTime = Integer.Parse(Console.ReadLine(), Globalization.CultureInfo.CurrentCulture) Console.WriteLine("Sleeping...") Threading.Thread.Sleep(millisecondsSleepTime) Console.WriteLine("Awake!") End Sub End Module
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Vlang
Vlang
import time import os   fn main() { sec := os.input("Enter number of seconds to sleep: ").i64() println("Sleeping…") time.sleep(time.Duration(sec * time.second)) println("Awake!") }
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Rust
Rust
use iced::{ // 0.2.0 button, Button, Column, Element, Length, Text, Sandbox, Settings, Space, };   #[derive(Debug, Copy, Clone)] struct Pressed; struct Simple { value: i32, button: button::State, }   impl Sandbox for Simple { type Message = Pressed;   fn new() -> Simple { Simple { ...
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Scala
Scala
import scala.swing.{ BorderPanel, Button, Label, MainFrame, SimpleSwingApplication } import scala.swing.event.ButtonClicked   object SimpleApp extends SimpleSwingApplication { def top = new MainFrame { contents = new BorderPanel { var nClicks = 0   val (button, label) = (new Button { text = "click me"...
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...
#Ada
Ada
with Ada.Text_IO; use Ada.Text_IO; with Ada.Calendar; use Ada.Calendar; with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; with Ada.Calendar.Conversions; use Ada.Calendar.Conversions; procedure ShowEpoch is etime : Time := To_Ada_Time (0); begin Put_Line (Image (Date => etime)); end ShowEpoch;
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...
#AppleScript
AppleScript
use AppleScript version "2.4" -- OS X 10.10 (Yosemite) or later use framework "Foundation" use scripting additions   local CocoaEpoch, UnixEpoch   -- Get the date 0 seconds from the Cocoa epoch. set CocoaEpoch to current application's class "NSDate"'s dateWithTimeIntervalSinceReferenceDate:(0) -- The way it's rendered ...
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#Kotlin
Kotlin
// version 1.1.2   import java.awt.* import java.awt.geom.Path2D import java.util.Random import javax.swing.*   class SierpinskiPentagon : JPanel() { // exterior angle private val degrees072 = Math.toRadians(72.0)   /* After scaling we'll have 2 sides plus a gap occupying the length of a side before ...
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: * * * * * * * * * * * * * * * ...
#Burlesque
Burlesque
{JPp{ -.'sgve! J{JL[2./+.' j.*PppP.+PPj.+}m[ j{J" "j.+.+}m[ .+ }{vv{"*"}}PPie} 's sv 4 'sgve!unsh
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#JavaScript
JavaScript
  <!-- SierpinskiTriangle.html --> <html> <head><title>Sierpinski Triangle Fractal</title> <script> // HF#1 Like in PARI/GP: return random number 0..max-1 function randgp(max) {return Math.floor(Math.random()*max)} // HF#2 Random hex color function randhclr() { return "#"+ ("00"+randgp(256).toString(16)).slice(-2)+...
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#jq
jq
include "turtle" {search: "."};   # Compute the curve using a Lindenmayer system of rules def rules: # "H" signfies Horizontal motion {X: "XX", H: "H--X++H++X--H", "": "H--X--X"};   def sierpinski($count): rules as $rules | def repeat($count): if $count == 0 then . else gsub("X"; $rules["X"]) | gs...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#Wren
Wren
import "timer" for Timer import "io" for Stdin, Stdout   System.write("Enter time to sleep in seconds: ") Stdout.flush() var secs while (true) { secs = Num.fromString(Stdin.readLine()) if (secs == null) { System.print("Not a number try again.") } else break } System.print("Sleeping...") Timer.sleep(...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#X86_Assembly
X86 Assembly
  ; x86_64 linux nasm   section .text   Sleep: mov rsi, 0 ; we wont use the second sleep arg, pass null to syscall sub rsp, 16 mov qword [rsp], rdi ; number of seconds the caller requested mov qword [rsp + 8], rsi ; we won't use the nanoseconds mov rdi, rsp ; pass the struct that's on the stack to mov rax, ...
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Scratch
Scratch
  when flag clicked # when program is run set counter to "0" # initialize counter object to zero set message to "There have been no clicks" show variable message # show the message object   when this sprite clicked # when button clicked hide message # hide the initial message chang...
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Sidef
Sidef
require('Gtk2') -> init   # Window. var window = %s<Gtk2::Window>.new window.signal_connect('destroy' => { %s<Gtk2>.main_quit })   # VBox. var vbox = %s<Gtk2::VBox>.new(0, 0) window.add(vbox)   # Label. var label = %s<Gtk2::Label>.new('There have been no clicks yet.') vbox.add(label)   # Button. var count = 0 var butto...
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...
#Arturo
Arturo
print to :date 0 ; convert UNIX timestamp: 0 to date   print now print to :integer now ; convert current date to UNIX timestamp
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...
#AWK
AWK
  # syntax: GAWK -f SHOW_THE_EPOCH.AWK # requires GNU Awk 4.0.1 or later BEGIN { print(strftime("%Y-%m-%d %H:%M:%S",0,1)) exit(0) }  
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#Lua
Lua
Bitmap.chaosgame = function(self, n, r, niters) local w, h, vertices = self.width, self.height, {} for i = 1, n do vertices[i] = { x = w/2 + w/2 * math.cos(math.pi/2+(i-1)*math.pi*2/n), y = h/2 - h/2 * math.sin(math.pi/2+(i-1)*math.pi*2/n) } end local x, y = w/2, h/2 for i = 1, niters do ...
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: * * * * * * * * * * * * * * * ...
#BQN
BQN
Sierp ← {" •" ⊏˜ (⌽↕2⋆𝕩)⌽˘∾˘∾⟜0¨∧´∘∨⌜˜⥊↕2⥊˜𝕩}
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#Julia
Julia
  using Luxor   function sierpinski(txy, levelsyet) nxy = zeros(6) if levelsyet > 0 for i in 1:6 pos = i < 5 ? i + 2 : i - 4 nxy[i] = (txy[i] + txy[pos]) / 2.0 end sierpinski([txy[1],txy[2],nxy[1],nxy[2],nxy[5],nxy[6]], levelsyet-1) sierpinski([nxy[1],nxy[...
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#Kotlin
Kotlin
import java.awt.* import javax.swing.JFrame import javax.swing.JPanel   fun main(args: Array<String>) { var i = 8 // Default if (args.any()) { try { i = args.first().toInt() } catch (e: NumberFormatException) { i = 8 println("Usage: 'java SierpinskyTriangl...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#XPL0
XPL0
int Microseconds; [Microseconds:= IntIn(0); Text(0, "Sleeping...^m^j"); DelayUS(Microseconds); Text(0, "Awake!^m^j"); ]
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#zig
zig
const std = @import("std"); const time = std.time; const warn = std.debug.warn;   pub fn main() void { warn("Sleeping...\n");   time.sleep(1000000000); // `sleep` uses nanoseconds   warn("Awake!\n"); }
http://rosettacode.org/wiki/Simple_windowed_application
Simple windowed application
Task Create a window that has:   a label that says   "There have been no clicks yet"   a button that says   "click me" Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
#Smalltalk
Smalltalk
|top clickCount lh button|   clickCount := 0. lh := ValueHolder with:'There have been no clicks yet'.   top := StandardSystemView label:'Rosetta Simple Window'. top extent:300@100. top add:((Label new labelChannel:lh) origin: 0 @ 10 corner: 1.0 @ 40). top add:((button := Button label:'Eat Me') origin: 10 @ 50 corner: 1...
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...
#BBC_BASIC
BBC BASIC
INSTALL @lib$+"DATELIB" PRINT FN_date$(0, "dd-MMM-yyyy")
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...
#C
C
#include <time.h> #include <stdio.h>   int main() { time_t t = 0; printf("%s", asctime(gmtime(&t))); return 0; }
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
pentaFlake[0] = RegularPolygon[5]; pentaFlake[n_] := GeometricTransformation[pentaFlake[n - 1], TranslationTransform /@ CirclePoints[{GoldenRatio^(2 n - 1), Pi/10}, 5]] Graphics@pentaFlake[4]
http://rosettacode.org/wiki/Sierpinski_pentagon
Sierpinski pentagon
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4. See also Sierpinski pentagon
#MATLAB
MATLAB
[x, x0] = deal(exp(1i*(0.5:.4:2.1)*pi)); for k = 1 : 4 x = x(:) + x0 * (1 + sqrt(5)) * (3 + sqrt(5)) ^(k - 1) / 2 ^ k; end patch('Faces', reshape(1 : 5 * 5 ^ k, 5, '')', 'Vertices', [real(x(:)) imag(x(:))]) axis image off
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: * * * * * * * * * * * * * * * ...
#C
C
#include <stdio.h>   #define SIZE (1 << 4) int main() { int x, y, i; for (y = SIZE - 1; y >= 0; y--, putchar('\n')) { for (i = 0; i < y; i++) putchar(' '); for (x = 0; x + y < SIZE; x++) printf((x & y) ? " " : "* "); } return 0; }
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#Logo
Logo
to sierpinski :n :length if :n = 0 [stop] repeat 3 [sierpinski :n-1 :length/2 fd :length rt 120] end seth 30 sierpinski 5 200
http://rosettacode.org/wiki/Sierpinski_triangle/Graphical
Sierpinski triangle/Graphical
Produce a graphical representation of a Sierpinski triangle of order N in any orientation. An example of Sierpinski's triangle (order = 8) looks like this:
#Lua
Lua
-- The argument 'tri' is a list of co-ords: {x1, y1, x2, y2, x3, y3} function sierpinski (tri, order) local new, p, t = {} if order > 0 then for i = 1, #tri do p = i + 2 if p > #tri then p = p - #tri end new[i] = (tri[i] + tri[p]) / 2 end sierpinski({t...
http://rosettacode.org/wiki/Sleep
Sleep
Task Write a program that does the following in this order: Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. Print "Sleeping..." Sleep the main thread for the given amount of time. ...
#zkl
zkl
seconds:=ask("Seconds to sleep: ").toFloat(); println("Sleeping..."); Atomic.sleep(seconds); # float, usually millisecond resolution println("Awake!");