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/Text_processing/2
Text processing/2
The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters...
#R
R
# Read in data from file dfr <- read.delim("d:/readings.txt", colClasses=c("character", rep(c("numeric", "integer"), 24))) dates <- strptime(dfr[,1], "%Y-%m-%d")   # Any bad values? dfr[which(is.na(dfr))]   # Any duplicated dates dates[duplicated(dates)]   # Number of rows with no bad values flags <- as.matrix(dfr[,seq...
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#gnuplot
gnuplot
print "\007"
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Go
Go
package main   import "fmt"   func main() { fmt.Print("\a") }
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Groovy
Groovy
println '\7'
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#Action.21
Action!
PROC Wait(BYTE frames) BYTE RTCLOK=$14 frames==+RTCLOK WHILE frames#RTCLOK DO OD RETURN   PROC Main() DEFINE PTR="CARD" PTR ARRAY num(12),obj(12) BYTE i,j   num(0)="first" num(1)="second" num(2)="third" num(3)="fourth" num(4)="fifth" num(5)="sixth" num(6)="seventh" num(7)="eight" num(8)="ninth" num(...
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#ActionScript
ActionScript
package {   import flash.display.Sprite; import flash.events.Event; import flash.events.KeyboardEvent; import flash.events.MouseEvent; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFormat; import flash.ui.Keyboard;   public class TwelveDaysOf...
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#Common_Lisp
Common Lisp
  (format t "~C[?1049h~C[H" (code-char #O33) (code-char #O33)) (format t "Alternate screen buffer~%") (loop for i from 5 downto 1 do (progn (format t "~%going back in ~a" i) (sleep 1) )) (format t "~C[?1049l" (code-char #O33))  
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#Emacs_Lisp
Emacs Lisp
#!/usr/local/bin/emacs --script ;; -*- lexical-binding: t; -*-   ;; "ESC [ ? 1049 h" - Enable alternative screen buffer (princ "\033[?1049h") (princ "Alternate screen buffer\n")   (let ((i 5)) (while (> i 0) (princ (format "\rgoing back in %d..." i)) ;; flush stdout (set-binary-mode 'stdout t) (sleep-...
http://rosettacode.org/wiki/Text_processing/1
Text processing/1
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. Often data is produced by one program, in the wrong format for later use by another program or person. In these situations another pr...
#11l
11l
V nodata = 0 V nodata_max = -1 [String] nodata_maxline V tot_file = 0.0 V num_file = 0   :start: L(line) File(:argv[1]).read().rtrim("\n").split("\n") V tot_line = 0.0 V num_line = 0   V field = line.split("\t") V date = field[0] V data = field[(1..).step(2)].map(f -> Float(f)) V flags = field[(2..)...
http://rosettacode.org/wiki/Terminal_control/Positional_read
Terminal control/Positional read
Determine the character displayed on the screen at column 3, row 6 and store that character in a variable. Note that it is permissible to utilize system or language provided methods or system provided facilities, system maintained records or available buffers or system maintained display records to achieve this task, r...
#Action.21
Action!
proc Main() byte CHARS, cursorinh=$2F0   graphics(0) cursorinh=1   position(2,2) printe("Action!")   CHARS=Locate(2,2) position(2,2) put(CHARS)   cursorinh=0 position(2,4) printf("Character at column 2 row 2 was %C",CHARS)   return
http://rosettacode.org/wiki/The_ISAAC_Cipher
The ISAAC Cipher
ISAAC is a cryptographically secure pseudo-random number generator (CSPRNG) and stream cipher. It was developed by Bob Jenkins from 1993 (http://burtleburtle.net/bob/rand/isaac.html) and placed in the Public Domain. ISAAC is fast - especially when optimised - and portable to most architectures in nearly all programming...
#Delphi
Delphi
  {$apptype console} PROGRAM RosettaIsaac; USES SysUtils;   // TASK globals VAR msg : STRING = 'a Top Secret secret'; VAR key : STRING = 'this is my secret key'; VAR xctx: STRING = ''; // XOR ciphertext VAR mctx: STRING = ''; // MOD ciphertext   // ISAAC globals // external results VAR randrsl: ARRAY[0..256] OF CARDIN...
http://rosettacode.org/wiki/Test_integerness
Test integerness
Mathematically, the integers Z are included in the rational numbers Q, which are included in the real numbers R, which can be generalized to the complex numbers C. This means that each of those larger sets, and the data types used to represent them, include some integers. Task[edit] Given a rational, real, or co...
#Elixir
Elixir
defmodule Test do def integer?(n) when n == trunc(n), do: true def integer?(_), do: false end   Enum.each([2, 2.0, 2.5, 2.000000000000001, 1.23e300, 1.0e-300, "123", '123', :"123"], fn n -> IO.puts "#{inspect n} is integer?: #{Test.integer?(n)}" end)
http://rosettacode.org/wiki/Test_integerness
Test integerness
Mathematically, the integers Z are included in the rational numbers Q, which are included in the real numbers R, which can be generalized to the complex numbers C. This means that each of those larger sets, and the data types used to represent them, include some integers. Task[edit] Given a rational, real, or co...
#Factor
Factor
USING: formatting io kernel math math.functions sequences ; IN: rosetta-code.test-integerness   GENERIC: integral? ( n -- ? )   M: real integral? [ ] [ >integer ] bi number= ; M: complex integral? >rect [ integral? ] [ 0 number= ] bi* and ;   GENERIC# fuzzy-int? 1 ( n tolerance -- ? )   M: real fuzzy-int? [ dup round -...
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use
Text processing/Max licenses in use
A company currently pays a fixed sum for the use of a particular licensed software package.   In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file. Assume the software's licensing daemon faithfully records a checkout event when a copy of the ...
#Lua
Lua
  filename = "mlijobs.txt" io.input( filename )   max_out, n_out = 0, 0 occurr_dates = {}   while true do line = io.read( "*line" ) if line == nil then break end   if string.find( line, "OUT" ) ~= nil then n_out = n_out + 1 if n_out > max_out then max_out = n_out occu...
http://rosettacode.org/wiki/Test_a_function
Test a function
Task Using a well-known testing-specific library/module/suite for your language, write some tests for your language's entry in Palindrome. If your language does not have a testing specific library well known to the language's community then state this or omit the language.
#EchoLisp
EchoLisp
  (assert (palindrome? "aba")) → #t (assert (palindrome? "abbbca") "palindrome fail") 💥 error: palindrome fail : assertion failed : (palindrome? abbbca)   (check-expect (palindrome? "aba") #t) → #t (check-expect (palindrome? "abcda") #f) → #t (check-expect (palindrome? "abcda") #t) 😐 warning: #t : check failed : (pal...
http://rosettacode.org/wiki/Test_a_function
Test a function
Task Using a well-known testing-specific library/module/suite for your language, write some tests for your language's entry in Palindrome. If your language does not have a testing specific library well known to the language's community then state this or omit the language.
#Erlang
Erlang
  -module( palindrome_tests ). -compile( export_all ). -include_lib( "eunit/include/eunit.hrl" ).   abcba_test() -> ?assert( palindrome:is_palindrome("abcba") ).   abcdef_test() -> ?assertNot( palindrome:is_palindrome("abcdef") ).  
http://rosettacode.org/wiki/Text_processing/2
Text processing/2
The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters...
#Racket
Racket
#lang racket (read-decimal-as-inexact #f) ;; files to read is a sequence, so it could be either a list or vector of files (define (text-processing/2 files-to-read) (define seen-datestamps (make-hash)) (define (datestamp-seen? ds) (hash-ref seen-datestamps ds #f)) (define (datestamp-seen! ds pos) (hash-set! seen-d...
http://rosettacode.org/wiki/Text_processing/2
Text processing/2
The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters...
#Raku
Raku
my $good-records; my $line; my %dates;   for lines() { $line++; / ^ (\d ** 4 '-' \d\d '-' \d\d) [ \h+ \d+'.'\d+ \h+ ('-'?\d+) ] ** 24 $ / or note "Bad format at line $line" and next; %dates.push: $0 => $line; $good-records++ if $1.all >= 1; }   say "$good-records good records out of ...
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Haskell
Haskell
main = putStr "\a"
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Icon_and_Unicon
Icon and Unicon
  procedure main () write ("\7") # ASCII 7 rings the bell under Bash end  
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#J
J
7{a. NB. noun a. is a complete ASCII ordered character vector.
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Java
Java
public class Bell{ public static void main(String[] args){ java.awt.Toolkit.getDefaultToolkit().beep();   //or   System.out.println((char)7); } }
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#Ada
Ada
with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;   procedure Twelve_Days_Of_Christmas is type Days is (First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth, Eleventh, Twelfth);   package E_IO is new Ada.Text_IO.Enumeration_IO(Days); use...
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#Forth
Forth
.\" \033[?1049h\033[H" \ preserve screen ." Press any key to return" ekey drop .\" \033[?1049l" \ restore screen
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#FreeBASIC
FreeBASIC
'' 640x480x8, with 3 pages Screen 12,,3 Windowtitle "Terminal control/Preserve screen"   '' text for working page #2 (visible page #0) Screenset 2, 0 Cls Print "This is the new screen, following a CLS"   '' text for working page #1 (visible page #0) Screenset 1, 0 Cls Print "This is the original screen"   ' page #0 is ...
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#Go
Go
package main   import ( "fmt" "time" )   func main() { fmt.Print("\033[?1049h\033[H") fmt.Println("Alternate screen buffer\n") s := "s" for i := 5; i > 0; i-- { if i == 1 { s = "" } fmt.Printf("\rgoing back in %d second%s...", i, s) time.Sleep(time.Sec...
http://rosettacode.org/wiki/Text_processing/1
Text processing/1
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. Often data is produced by one program, in the wrong format for later use by another program or person. In these situations another pr...
#Ada
Ada
with Ada.Text_IO; use Ada.Text_IO; with Strings_Edit; use Strings_Edit; with Strings_Edit.Floats; use Strings_Edit.Floats; with Strings_Edit.Integers; use Strings_Edit.Integers;   procedure Data_Munging is Syntax_Error : exception; type Gap_Data is record Count  : Natural := 0; ...
http://rosettacode.org/wiki/Terminal_control/Positional_read
Terminal control/Positional read
Determine the character displayed on the screen at column 3, row 6 and store that character in a variable. Note that it is permissible to utilize system or language provided methods or system provided facilities, system maintained records or available buffers or system maintained display records to achieve this task, r...
#AutoHotkey
AutoHotkey
DllCall( "AllocConsole" ) ; create a console if not launched from one hConsole := DllCall( "GetStdHandle", int, STDOUT := -11 ) Loop 10 { Loop 10 { Random, asc, % asc("A"), % Asc("Z") WriteConsole(hConsole, Chr(asc)) } WriteConsole(hConsole, "`n") }   MsgBox % ReadConsoleOutputCharacter(hConsole, 1, 3, 6)   ; =...
http://rosettacode.org/wiki/Terminal_control/Positional_read
Terminal control/Positional read
Determine the character displayed on the screen at column 3, row 6 and store that character in a variable. Note that it is permissible to utilize system or language provided methods or system provided facilities, system maintained records or available buffers or system maintained display records to achieve this task, r...
#BASIC
BASIC
10 DEF FN C(H) = SCRN( H - 1,(V - 1) * 2) + SCRN( H - 1,(V - 1) * 2 + 1) * 16 20 LET V = 6:C$ = CHR$ ( FN C(3))
http://rosettacode.org/wiki/The_ISAAC_Cipher
The ISAAC Cipher
ISAAC is a cryptographically secure pseudo-random number generator (CSPRNG) and stream cipher. It was developed by Bob Jenkins from 1993 (http://burtleburtle.net/bob/rand/isaac.html) and placed in the Public Domain. ISAAC is fast - especially when optimised - and portable to most architectures in nearly all programming...
#ECMAScript
ECMAScript
randrsl = new Uint32Array(256); randcnt = 0; mm = new Uint32Array(256); aa = 0; bb = 0; cc = 0;   function isaac() { cc++; bb += cc; for(var i = 0; i < 256; i++) { var x = mm[i]; var sw = i & 3; if(sw == 0) aa = aa ^ (aa << 13); els...
http://rosettacode.org/wiki/Test_integerness
Test integerness
Mathematically, the integers Z are included in the rational numbers Q, which are included in the real numbers R, which can be generalized to the complex numbers C. This means that each of those larger sets, and the data types used to represent them, include some integers. Task[edit] Given a rational, real, or co...
#Fortran
Fortran
MODULE ZERMELO !Approach the foundations of mathematics. CONTAINS LOGICAL FUNCTION ISINTEGRAL(X) !A whole number? REAL*8 X !Alas, this is not really a REAL number. INTEGER*8 N !Largest available. IF (ISNAN(X)) THEN !Avoid some sillyness. ISINTEGRAL = .FALSE. ...
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use
Text processing/Max licenses in use
A company currently pays a fixed sum for the use of a particular licensed software package.   In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file. Assume the software's licensing daemon faithfully records a checkout event when a copy of the ...
#M2000_Interpreter
M2000 Interpreter
  Module Checkit { Document a$, max_time$ Load.doc a$, "mlijobs.txt" const dl$=" ", nl$={ } Def long m, out, max_out=-1 m=Paragraph(a$, 0) If Forward(a$,m) then { While m { job$=Paragraph$(a$,(m)) out+=If(Piece$(job$,dl$,2)="OUT"...
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use
Text processing/Max licenses in use
A company currently pays a fixed sum for the use of a particular licensed software package.   In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file. Assume the software's licensing daemon faithfully records a checkout event when a copy of the ...
#M4
M4
  divert(-1) define(`current',0) define(`max',0) define(`OUT',`define(`current',incr(current))`'ifelse(eval(current>max),1, `define(`max',current)`'divert(-1)`'undivert(1)`'divert(1)', `ifelse(current,max,`divert(1)undivert(1)')')') define(`IN',`define(`current',decr(current))') define(`for',`divert(-1)') include...
http://rosettacode.org/wiki/Test_a_function
Test a function
Task Using a well-known testing-specific library/module/suite for your language, write some tests for your language's entry in Palindrome. If your language does not have a testing specific library well known to the language's community then state this or omit the language.
#Euphoria
Euphoria
  --unittest in standard library 4.0+ include std/unittest.e include palendrome.e --routines to be tested   object p = "12321"   test_equal("12321", 1, isPalindrome(p)) test_equal("r12321", 1, isPalindrome(reverse(p)))   test_report()    
http://rosettacode.org/wiki/Test_a_function
Test a function
Task Using a well-known testing-specific library/module/suite for your language, write some tests for your language's entry in Palindrome. If your language does not have a testing specific library well known to the language's community then state this or omit the language.
#F.23
F#
let palindrome (s : string) = let a = s.ToUpper().ToCharArray() Array.rev a = a     open NUnit.Framework   [<TestFixture>] type TestCases() = [<Test>] member x.Test01() = Assert.IsTrue(palindrome "radar")   [<Test>] member x.Test02() = Assert.IsFalse(palindrome "hello")
http://rosettacode.org/wiki/Text_processing/2
Text processing/2
The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters...
#REXX
REXX
/*REXX program to process instrument data from a data file. */ numeric digits 20 /*allow for bigger numbers. */ ifid='READINGS.TXT' /*name of the input file. */ ofid='READINGS.OUT' /* " " " output " ...
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Julia
Julia
  println("This should ring a bell.\a")  
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Kotlin
Kotlin
// version 1.1.2   fun main(args: Array<String>) { println("\u0007") }
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Lasso
Lasso
stdoutnl('\a')
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Logo
Logo
type char 7
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#ALGOL_68
ALGOL 68
BEGIN []STRING labels = ("first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth");   []STRING gifts = ("A partridge in a pear tree.", "Two turtle doves, and", "Three F...
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#Java
Java
public class PreserveScreen { public static void main(String[] args) throws InterruptedException { System.out.print("\033[?1049h\033[H"); System.out.println("Alternate screen buffer\n"); for (int i = 5; i > 0; i--) { String s = (i > 1) ? "s" : ""; System.out.printf("\...
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#JavaScript
JavaScript
(function() { var orig= document.body.innerHTML document.body.innerHTML= ''; setTimeout(function() { document.body.innerHTML= 'something'; setTimeout(function() { document.body.innerHTML= orig; }, 1000); }, 1000); })();
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#Julia
Julia
const ESC = "\u001B" # escape code   print("$ESC[?1049h$ESC[H") print("\n\nNow using an alternate screen buffer. Returning after count of: ") foreach(x -> (sleep(1); print(" $x")), 5:-1:0) print("$ESC[?1049l\n\n\n")    
http://rosettacode.org/wiki/Terminal_control/Hiding_the_cursor
Terminal control/Hiding the cursor
The task is to hide the cursor and show it again.
#Action.21
Action!
PROC Wait(BYTE frames) BYTE RTCLOK=$14 frames==+RTCLOK WHILE frames#RTCLOK DO OD RETURN   PROC Main() BYTE CRSINH=$02F0 ;Controls visibility of cursor   Print("Hiding the cursor...") Wait(50) CRSINH=1 PutE() ;put the new line character to force hide the cursor Wait(50)   Print("Showing the cursor...")...
http://rosettacode.org/wiki/Terminal_control/Inverse_video
Terminal control/Inverse video
Task Display a word in inverse video   (or reverse video)   followed by a word in normal video.
#11l
11l
print("\033[7mReversed\033[m Normal")
http://rosettacode.org/wiki/Text_processing/1
Text processing/1
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. Often data is produced by one program, in the wrong format for later use by another program or person. In these situations another pr...
#Aime
Aime
integer bads, count, max_bads; file f; list l; real s; text bad_day, worst_day;   f.stdin;   max_bads = count = bads = s = 0;   while (f.list(l, 0) ^ -1) { integer i;   i = 2; while (i < 49) { if (0 < atoi(l[i])) { count += 1; s += atof(l[i - 1]); if (max_bads < b...
http://rosettacode.org/wiki/Terminal_control/Positional_read
Terminal control/Positional read
Determine the character displayed on the screen at column 3, row 6 and store that character in a variable. Note that it is permissible to utilize system or language provided methods or system provided facilities, system maintained records or available buffers or system maintained display records to achieve this task, r...
#C
C
#include <windows.h> #include <wchar.h>   int main() { CONSOLE_SCREEN_BUFFER_INFO info; COORD pos; HANDLE conout; long len; wchar_t c;   /* Create a handle to the console screen. */ conout = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0...
http://rosettacode.org/wiki/Terminal_control/Positional_read
Terminal control/Positional read
Determine the character displayed on the screen at column 3, row 6 and store that character in a variable. Note that it is permissible to utilize system or language provided methods or system provided facilities, system maintained records or available buffers or system maintained display records to achieve this task, r...
#Common_Lisp
Common Lisp
(defun positional-read () (with-screen (scr :input-blocking t :input-echoing nil :cursor-visible nil) ;; print random characters in a 10x20 grid (loop for i from 0 to 9 do (loop for j from 0 to 19 do (add-char scr (+ 33 (random 94)) :y i :x j))) ;; highlight char to extract at row 6...
http://rosettacode.org/wiki/The_ISAAC_Cipher
The ISAAC Cipher
ISAAC is a cryptographically secure pseudo-random number generator (CSPRNG) and stream cipher. It was developed by Bob Jenkins from 1993 (http://burtleburtle.net/bob/rand/isaac.html) and placed in the Public Domain. ISAAC is fast - especially when optimised - and portable to most architectures in nearly all programming...
#FreeBASIC
FreeBASIC
' version 03-11-2016 ' compile with: fbc -s console   Dim Shared As UInteger<32> randrsl(256), randcnt Static Shared As UInteger<32> mm(256) Static Shared As UInteger<32> aa, bb ,cc   Sub ISAAC()   Dim As UInteger<32> i, x, y   cc = cc + 1 bb = bb + cc   For i = 0 To 256 -1 x = mm(i) Sel...
http://rosettacode.org/wiki/Test_integerness
Test integerness
Mathematically, the integers Z are included in the rational numbers Q, which are included in the real numbers R, which can be generalized to the complex numbers C. This means that each of those larger sets, and the data types used to represent them, include some integers. Task[edit] Given a rational, real, or co...
#Free_Pascal
Free Pascal
// in FPC 3.2.0 the definition of `integer` still depends on the compiler mode {$mode objFPC}   uses // used for `isInfinite`, `isNan` and `fMod` math, // NB: `ucomplex`’s `complex` isn’t a simple data type as ISO 10206 requires ucomplex;   { --- determines whether a `float` value is (almost) an `integer` ------ } ...
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use
Text processing/Max licenses in use
A company currently pays a fixed sum for the use of a particular licensed software package.   In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file. Assume the software's licensing daemon faithfully records a checkout event when a copy of the ...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
LC = 0; LCMax = 0; Scan[ If[MemberQ[#, "OUT"], LC++; If[LCMax < LC, LCMax = LC; LCMaxtimes = {};]; If[LCMax == LC, AppendTo[LCMaxtimes, #[[4]]]], LC--;] &, Import["mlijobs.txt", "Table"]] Print["The maximum number of licenses used was ", LCMax, ", at ", LCMaxtimes]
http://rosettacode.org/wiki/Test_a_function
Test a function
Task Using a well-known testing-specific library/module/suite for your language, write some tests for your language's entry in Palindrome. If your language does not have a testing specific library well known to the language's community then state this or omit the language.
#Factor
Factor
USING: kernel sequences ; IN: palindrome   : palindrome? ( string -- ? ) dup reverse = ;
http://rosettacode.org/wiki/Test_a_function
Test a function
Task Using a well-known testing-specific library/module/suite for your language, write some tests for your language's entry in Palindrome. If your language does not have a testing specific library well known to the language's community then state this or omit the language.
#Fantom
Fantom
  class TestPalindrome : Test { public Void testIsPalindrome () { verify(Palindrome.isPalindrome("")) verify(Palindrome.isPalindrome("a")) verify(Palindrome.isPalindrome("aa")) verify(Palindrome.isPalindrome("aba")) verifyFalse(Palindrome.isPalindrome("abb")) verify(Palindrome.isPalindrome("...
http://rosettacode.org/wiki/Text_processing/2
Text processing/2
The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters...
#Ruby
Ruby
require 'set'   def munge2(readings, debug=false) datePat = /^\d{4}-\d{2}-\d{2}/ valuPat = /^[-+]?\d+\.\d+/ statPat = /^-?\d+/ totalLines = 0 dupdate, badform, badlen, badreading = Set[], Set[], Set[], 0 datestamps = Set[[]] for line in readings totalLines += 1 fields = line.split(/\t/)...
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Lua
Lua
print("\a")
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#M2000_Interpreter
M2000 Interpreter
  Module CheckIt { After 300 {beep} Print "Begin" for i=0 to 100 { wait 10 Print i } Print "End" } CheckIt  
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
Print["\007"]
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#MUMPS
MUMPS
write $char(7)
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#AppleScript
AppleScript
set gifts to {"A partridge in a pear tree.", "Two turtle doves, and", ¬ "Three French hens,", "Four calling birds,", ¬ "Five gold rings,", "Six geese a-laying,", ¬ "Seven swans a-swimming,", "Eight maids a-milking,", ¬ "Nine ladies dancing,", "Ten lords a-leaping,", ¬ "Eleven pipers piping,", "Twelve drummers drum...
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#Kotlin
Kotlin
// version 1.1.2   const val ESC = "\u001B"   fun main(args: Array<String>) { print("$ESC[?1049h$ESC[H") println("Alternate screen buffer") for(i in 5 downTo 1) { print("\rGoing back in $i second${if (i != 1) "s" else ""}...") Thread.sleep(1000) } print("$ESC[?1049l") }
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#M2000_Interpreter
M2000 Interpreter
  Module PreserveScreen { Bold 1 Font "Arial" Paper=#225511 SplitScreenRow=0 Cls Paper, SplitScreenRow Print "Test" Gosub GetState Font "Tahoma" Bold 1 : Italic 1: Pen 15 cls 0, 5 For i=1 to 100 : Print i: Next i Move 6000,6000 For i=1000 to ...
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
Run["tput smcup"] (* Save the display *) Run["echo Hello"] Pause[5] (* Wait five seconds *) Run["tput rmcup"]
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#Nim
Nim
import os   echo "\e[?1049h\e[H" echo "Alternate buffer!"   for i in countdown(5, 1): echo "Going back in: ", i sleep 1000   echo "\e[?1049l"
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#Perl
Perl
print "\033[?1049h\033[H"; print "Alternate screen buffer\n";   for (my $i = 5; $i > 0; --$i) { print "going back in $i...\n"; sleep(1); }   print "\033[?1049l";
http://rosettacode.org/wiki/Terminal_control/Hiding_the_cursor
Terminal control/Hiding the cursor
The task is to hide the cursor and show it again.
#Ada
Ada
with Ada.Text_Io;   with Ansi;   procedure Hiding is use Ada.Text_Io; begin Put ("Hiding the cursor for 2.0 seconds..."); delay 0.500; Put (Ansi.Hide); delay 2.000; Put ("And showing again."); delay 0.500; Put (Ansi.Show); delay 2.000; New_Line; end Hiding;
http://rosettacode.org/wiki/Terminal_control/Hiding_the_cursor
Terminal control/Hiding the cursor
The task is to hide the cursor and show it again.
#Arturo
Arturo
cursor false print "hiding the cursor"   pause 2000   cursor true print "showing the cursor"
http://rosettacode.org/wiki/Terminal_control/Hiding_the_cursor
Terminal control/Hiding the cursor
The task is to hide the cursor and show it again.
#AutoHotkey
AutoHotkey
DllCall("AllocConsole") ; Create a console if not launched from one hConsole := DllCall("GetStdHandle", UInt, STDOUT := -11)   VarSetCapacity(cci, 8) ; CONSOLE_CURSOR_INFO structure DllCall("GetConsoleCursorInfo", UPtr, hConsole, UPtr, &cci) NumPut(0, cci, 4) DllCall("SetConsoleCursorInfo", UPtr, hConsole, UPtr, &cci)...
http://rosettacode.org/wiki/Terminal_control/Inverse_video
Terminal control/Inverse video
Task Display a word in inverse video   (or reverse video)   followed by a word in normal video.
#6502_Assembly
6502 Assembly
tmpx -i inverse-video.s -o inverse-video.prg
http://rosettacode.org/wiki/Terminal_control/Inverse_video
Terminal control/Inverse video
Task Display a word in inverse video   (or reverse video)   followed by a word in normal video.
#Action.21
Action!
PROC PrintInv(CHAR ARRAY a) BYTE i   IF a(0)>0 THEN FOR i=1 TO a(0) DO Put(a(i)%$80) OD FI RETURN   PROC Main() Position(2,2)   PrintInv("Inverse") Print(" video") RETURN
http://rosettacode.org/wiki/Terminal_control/Inverse_video
Terminal control/Inverse video
Task Display a word in inverse video   (or reverse video)   followed by a word in normal video.
#Ada
Ada
with Ada.Text_IO; use Ada.Text_IO;   procedure Reverse_Video is   Rev_Video  : String := Ascii.ESC & "[7m"; Norm_Video : String := Ascii.ESC & "[m";   begin Put (Rev_Video & "Reversed"); Put (Norm_Video & " Normal"); end Reverse_Video;  
http://rosettacode.org/wiki/Terminal_control/Inverse_video
Terminal control/Inverse video
Task Display a word in inverse video   (or reverse video)   followed by a word in normal video.
#ARM_Assembly
ARM Assembly
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Program Start   .equ ramarea, 0x02000000 .equ CursorX,ramarea .equ CursorY,ramarea+1     ProgramStart: mov sp,#0x03000000 ;Init Stack Pointer   mov r4,#0x04000000 ;DISPCNT -LCD Cont...
http://rosettacode.org/wiki/Ternary_logic
Ternary logic
This page uses content from Wikipedia. The original article was at Ternary logic. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) In logic, a three-valued logic (also trivalent, ternary, or trinary...
#Action.21
Action!
DEFINE TERNARY="BYTE" DEFINE FALSE="0" DEFINE MAYBE="1" DEFINE TRUE="2"   PROC PrintT(TERNARY a) IF a=FALSE THEN Print("F") ELSEIF a=MAYBE THEN Print("?") ELSE Print("T") FI RETURN   TERNARY FUNC NotT(TERNARY a) RETURN (TRUE-a)   TERNARY FUNC AndT(TERNARY a,b) IF a<b THEN RETURN (a) FI RETURN (b)   TERNARY FU...
http://rosettacode.org/wiki/Terminal_control/Display_an_extended_character
Terminal control/Display an extended character
Task Display an extended (non ASCII) character onto the terminal. Specifically, display a   £   (GBP currency sign).
#11l
11l
print(‘£’)
http://rosettacode.org/wiki/Text_processing/1
Text processing/1
This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion. Often data is produced by one program, in the wrong format for later use by another program or person. In these situations another pr...
#ALGOL_68
ALGOL 68
INT no data := 0; # Current run of consecutive flags<0 in lines of file # INT no data max := -1; # Max consecutive flags<0 in lines of file # FLEX[0]STRING no data max line; # ... and line number(s) where it occurs #   REAL tot file := 0; # Sum of file data # INT num file := 0; ...
http://rosettacode.org/wiki/Terminal_control/Positional_read
Terminal control/Positional read
Determine the character displayed on the screen at column 3, row 6 and store that character in a variable. Note that it is permissible to utilize system or language provided methods or system provided facilities, system maintained records or available buffers or system maintained display records to achieve this task, r...
#Go
Go
package main   /* #include <windows.h> */ import "C" import "fmt"   func main() { for i := 0; i < 80*25; i++ { fmt.Print("A") // fill 80 x 25 console with 'A's } fmt.Println() conOut := C.GetStdHandle(C.STD_OUTPUT_HANDLE) info := C.CONSOLE_SCREEN_BUFFER_INFO{} pos := C.COORD{} C.Get...
http://rosettacode.org/wiki/Terminal_control/Positional_read
Terminal control/Positional read
Determine the character displayed on the screen at column 3, row 6 and store that character in a variable. Note that it is permissible to utilize system or language provided methods or system provided facilities, system maintained records or available buffers or system maintained display records to achieve this task, r...
#Julia
Julia
using LibNCurses   randtxt(n) = foldl(*, rand(split("1234567890abcdefghijklmnopqrstuvwxyz", ""), n))   initscr()   for i in 1:20 LibNCurses.mvwaddstr(i, 1, randtxt(50)) end   row = rand(1:20) col = rand(1:50) ch = LibNCurses.winch(row, col) LibNCurses.mvwaddstr(col, 52, "The character at ($row, $col) is $ch.") )  
http://rosettacode.org/wiki/Terminal_control/Positional_read
Terminal control/Positional read
Determine the character displayed on the screen at column 3, row 6 and store that character in a variable. Note that it is permissible to utilize system or language provided methods or system provided facilities, system maintained records or available buffers or system maintained display records to achieve this task, r...
#Kotlin
Kotlin
// Kotlin Native version 0.3   import kotlinx.cinterop.* import win32.*   fun main(args: Array<String>) { for (i in 0 until (80 * 25)) print("A") // fill 80 x 25 console with 'A's println() memScoped { val conOut = GetStdHandle(-11) val info = alloc<CONSOLE_SCREEN_BUFFER_INFO>() ...
http://rosettacode.org/wiki/The_ISAAC_Cipher
The ISAAC Cipher
ISAAC is a cryptographically secure pseudo-random number generator (CSPRNG) and stream cipher. It was developed by Bob Jenkins from 1993 (http://burtleburtle.net/bob/rand/isaac.html) and placed in the Public Domain. ISAAC is fast - especially when optimised - and portable to most architectures in nearly all programming...
#Go
Go
package main   import "fmt"   const ( msg = "a Top Secret secret" key = "this is my secret key" )   func main() { var z state z.seed(key) fmt.Println("Message: ", msg) fmt.Println("Key  : ", key) fmt.Println("XOR  : ", z.vernam(msg)) }   type state struct { aa, bb, cc uint32 mm ...
http://rosettacode.org/wiki/Test_integerness
Test integerness
Mathematically, the integers Z are included in the rational numbers Q, which are included in the real numbers R, which can be generalized to the complex numbers C. This means that each of those larger sets, and the data types used to represent them, include some integers. Task[edit] Given a rational, real, or co...
#Go
Go
package main   import ( "fmt" "math" "math/big" "reflect" "strings" "unsafe" )   // Go provides an integerness test only for the big.Rat and big.Float types // in the standard library.   // The fundamental piece of code needed for built-in floating point types // is a test on the float64 type:   func Float64IsInt...
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use
Text processing/Max licenses in use
A company currently pays a fixed sum for the use of a particular licensed software package.   In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file. Assume the software's licensing daemon faithfully records a checkout event when a copy of the ...
#MAXScript
MAXScript
fn licencesInUse = ( local logFile = openFile "mlijobs.txt" local out = 0 local maxOut = -1 local maxTimes = #()   while not EOF logFile do ( line = readLine logFile   if findString line "OUT" != undefined then ( out += 1 ) else ( ...
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use
Text processing/Max licenses in use
A company currently pays a fixed sum for the use of a particular licensed software package.   In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file. Assume the software's licensing daemon faithfully records a checkout event when a copy of the ...
#Nim
Nim
import strutils   var curOut = 0 maxOut = -1 maxTimes = newSeq[string]()   for job in lines "mlijobs.txt": if "OUT" in job: inc curOut else: dec curOut if curOut > maxOut: maxOut = curOut maxTimes.setLen(0) if curOut == maxOut: maxTimes.add job.split[3]   echo "Maximum simultaneous license use i...
http://rosettacode.org/wiki/Test_a_function
Test a function
Task Using a well-known testing-specific library/module/suite for your language, write some tests for your language's entry in Palindrome. If your language does not have a testing specific library well known to the language's community then state this or omit the language.
#Fortran
Fortran
  Sub StrReverse(Byref text As String) Dim As Integer x, lt = Len(text) For x = 0 To lt Shr 1 - 1 Swap text[x], text[lt - x - 1] Next x   End Sub   Sub Replace(Byref T As String, Byref I As String, Byref S As String, Byval A As Integer = 1) Var p = Instr(A, T, I), li = Len(I), ls = Len(S) : If l...
http://rosettacode.org/wiki/Text_processing/2
Text processing/2
The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters...
#Scala
Scala
object DataMunging2 { import scala.io.Source import scala.collection.immutable.{TreeMap => Map}   val pattern = """^(\d+-\d+-\d+)""" + """\s+(\d+\.\d+)\s+(-?\d+)""" * 24 + "$" r;   def main(args: Array[String]) { val files = args map (new java.io.File(_)) filter (file => file.isFile && file.canRead) val...
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Nanoquery
Nanoquery
print chr(7)
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Nemerle
Nemerle
using System.Console;   module Beep { Main() : void { Write("\a"); System.Threading.Thread.Sleep(1000); Beep(); System.Threading.Thread.Sleep(1000); Beep(2600, 1000); // limited OS support } }
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#NetRexx
NetRexx
/* NetRexx */ options replace format comments java crossref symbols binary   runSample(arg) return   -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ method runSample(arg) private static do BEL = 8x07 jtk = java.awt.toolkit.getDefaultToolkit() say 'Bing!'(Rexx BEL).d2c ...
http://rosettacode.org/wiki/Terminal_control/Ringing_the_terminal_bell
Terminal control/Ringing the terminal bell
Task Make the terminal running the program ring its "bell". On modern terminal emulators, this may be done by playing some other sound which might or might not be configurable, or by flashing the title bar or inverting the colors of the screen, but was classically a physical bell within the terminal.   It is usua...
#Nim
Nim
echo "\a"
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#Arturo
Arturo
gifts: [ "A partridge in a pear tree." "Two turtle doves" "Three french hens" "Four calling birds" "Five golden rings" "Six geese a-laying" "Seven swans a-swimming" "Eight maids a-milking" "Nine ladies dancing" "Ten lords a-leaping" "Eleven pipers piping" "Twelve drummers...
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#Phix
Phix
without js -- (save_text_image, sleep, display_text_image) sequence s = save_text_image({1,1}, {25,80}) clear_screen() puts(1,"\n\n *** hello ***\n") sleep(5) display_text_image({1,1}, s) sleep(3)
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#PicoLisp
PicoLisp
#!/usr/bin/picolisp /usr/lib/picolisp/lib.l   (call 'tput "smcup") (prinl "something") (wait 3000) (call 'tput "rmcup")   (bye)
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#Python
Python
#!/usr/bin/env python   import time   print "\033[?1049h\033[H" print "Alternate buffer!"   for i in xrange(5, 0, -1): print "Going back in:", i time.sleep(1)   print "\033[?1049l"
http://rosettacode.org/wiki/Terminal_control/Preserve_screen
Terminal control/Preserve screen
Task Clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved.   If the implement...
#R
R
cat("\033[?1049h\033[H") cat("Alternate screen buffer\n") for (i in 5:1) { cat("\rgoing back in ", i, "...", sep = "") Sys.sleep(1) cat("\33[2J") } cat("\033[?1049l")
http://rosettacode.org/wiki/Terminal_control/Hiding_the_cursor
Terminal control/Hiding the cursor
The task is to hide the cursor and show it again.
#BaCon
BaCon
' Hiding the cursor for an ANSI compliant terminal CURSOR OFF CURSOR ON
http://rosettacode.org/wiki/Terminal_control/Hiding_the_cursor
Terminal control/Hiding the cursor
The task is to hide the cursor and show it again.
#BASIC
BASIC
'hide the cursor: LOCATE , , 0 'wait for a keypress... SLEEP 'show the cursor: LOCATE , , 1
http://rosettacode.org/wiki/Terminal_control/Hiding_the_cursor
Terminal control/Hiding the cursor
The task is to hide the cursor and show it again.
#BBC_BASIC
BBC BASIC
OFF : REM Hide the cursor WAIT 400 ON  : REM Show the cursor again
http://rosettacode.org/wiki/Terminal_control/Hiding_the_cursor
Terminal control/Hiding the cursor
The task is to hide the cursor and show it again.
#Befunge
Befunge
"l52?["39*,,,,,, >v "retnE sserP">:#,_v> "h52?["39*,,,,,,@ >~
http://rosettacode.org/wiki/Terminal_control/Inverse_video
Terminal control/Inverse video
Task Display a word in inverse video   (or reverse video)   followed by a word in normal video.
#AutoHotkey
AutoHotkey
DllCall( "AllocConsole" ) ; create a console if not launched from one hConsole := DllCall( "GetStdHandle", int, STDOUT := -11 )   SetConsoleTextAttribute(hConsole, 0x70) ; gray background, black foreground FileAppend, Reversed`n, CONOUT$ ; print to stdout   SetConsoleTextAttribute(hConsole, 0x07) ; black background, gr...
http://rosettacode.org/wiki/Terminal_control/Inverse_video
Terminal control/Inverse video
Task Display a word in inverse video   (or reverse video)   followed by a word in normal video.
#AWK
AWK
BEGIN { system ("tput rev") print "foo" system ("tput sgr0") print "bar" }
http://rosettacode.org/wiki/Terminal_control/Inverse_video
Terminal control/Inverse video
Task Display a word in inverse video   (or reverse video)   followed by a word in normal video.
#Axe
Axe
Fix 3 Disp "INVERTED" Fix 2 Disp "REGULAR",i Pause 4500