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/Terminal_control/Cursor_movement
Terminal control/Cursor movement
Task Demonstrate how to achieve movement of the terminal cursor: how to move the cursor one position to the left how to move the cursor one position to the right how to move the cursor up one line (without affecting its horizontal position) how to move the cursor down one line (without affecting its horizontal po...
#C.23
C#
static void Main(string[] args) { //There will be a 3 second pause between each cursor movement. Console.Write("\n\n\n\n Cursor is here --> "); System.Threading.Thread.Sleep(3000); Console.CursorLeft = Console.CursorLeft - 1; //Console.CursorLeft += -1 is an alternative. System.Threading.Threa...
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#PHP
PHP
  echo "\033[".$x.",".$y."H"; // Position line $y and column $x. echo "\033[".$n."A"; // Up $n lines. echo "\033[".$n."B"; // Down $n lines. echo "\033[".$n."C"; // Forward $n columns. echo "\033[".$n."D"; // Backward $n columns. echo "\033[2J"; // Clear the screen, move to (0,0).  
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#PicoLisp
PicoLisp
(call 'tput "cup" 6 3) (prin "Hello")
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#PowerShell
PowerShell
$Host.UI.RawUI.CursorPosition = New-Object System.Management.Automation.Host.Coordinates 2,5 $Host.UI.Write('Hello')
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#PureBasic
PureBasic
EnableGraphicalConsole(#True) ConsoleLocate(3,6) Print("Hello")
http://rosettacode.org/wiki/Tau_number
Tau number
A Tau number is a positive integer divisible by the count of its positive divisors. Task Show the first   100   Tau numbers. The numbers shall be generated during run-time (i.e. the code may not contain string literals, sets/arrays of integers, or alike). Related task  Tau function
#11l
11l
F tau(n) V ans = 0 V i = 1 V j = 1 L i * i <= n I 0 == n % i ans++ j = n I/ i I j != i ans++ i++ R ans   F is_tau_number(n) I n <= 0 R 0B R 0 == n % tau(n)   V n = 1 [Int] ans L ans.len < 100 I is_tau_number(n) ans.append(n) n++ p...
http://rosettacode.org/wiki/Teacup_rim_text
Teacup rim text
On a set of coasters we have, there's a picture of a teacup.   On the rim of the teacup the word   TEA   appears a number of times separated by bullet characters   (•). It occurred to me that if the bullet were removed and the words run together,   you could start at any letter and still end up with a meaningful three...
#AWK
AWK
  # syntax: GAWK -f TEACUP_RIM_TEXT.AWK UNIXDICT.TXT # # sorting: # PROCINFO["sorted_in"] is used by GAWK # SORTTYPE is used by Thompson Automation's TAWK # { for (i=1; i<=NF; i++) { arr[tolower($i)] = 0 } } END { PROCINFO["sorted_in"] = "@ind_str_asc" ; SORTTYPE = 1 for (i in arr) { leng ...
http://rosettacode.org/wiki/Terminal_control/Clear_the_screen
Terminal control/Clear the screen
Task Clear the terminal window.
#AArch64_Assembly
AArch64 Assembly
  /* ARM assembly AARCH64 Raspberry PI 3B */ /* program clearScreen.s */   /*******************************************/ /* Constantes file */ /*******************************************/ /* for this file see task include a file in language AArch64 assembly*/ .include "../includeConstantesAR...
http://rosettacode.org/wiki/Terminal_control/Clear_the_screen
Terminal control/Clear the screen
Task Clear the terminal window.
#Action.21
Action!
proc Main() Put(125) return
http://rosettacode.org/wiki/Terminal_control/Clear_the_screen
Terminal control/Clear the screen
Task Clear the terminal window.
#Ada
Ada
with Ada.Text_IO; procedure CLS is begin Ada.Text_IO.Put(ASCII.ESC & "[2J"); end CLS;
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...
#Elena
Elena
import extensions; import system'routines; import system'collections;   sealed class Trit { bool _value;   bool cast() = _value;   constructor(v) { if (v != nil) { _value := cast bool(v); } }   Trit equivalent(b) = _value.equal(cast bool(b)) \ ...
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).
#Yabasic
Yabasic
print chr$(156)
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).
#zkl
zkl
"\u00a3 \Ua3;".println() //-->£ £
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...
#Forth
Forth
\ data munging   \ 1991-03-30[\t10.000\t[-]1]*24   \ 1. mean of valid (flag > 0) values per day and overall \ 2. length of longest run of invalid values, and when it happened   fvariable day-sum variable day-n   fvariable total-sum variable total-n   10 constant date-size \ yyyy-mm-dd create cur-date date-size allot...
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...
#Python
Python
import random import collections   INT_MASK = 0xFFFFFFFF # we use this to emulate 32-bit overflow semantics by masking off higher bits after operations   class IsaacRandom(random.Random): """ Random number generator using the ISAAC algorithm. """   def seed(self, seed=None): """ In...
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...
#Ruby
Ruby
  class Numeric def to_i? self == self.to_i rescue false end end   # Demo ar = [25.000000, 24.999999, 25.000100, -2.1e120, -5e-2, # Floats Float::NAN, Float::INFINITY, # more Floats 2r, 2.5r, # Rationals 2+0i, 2+0.0i, 5-5i] ...
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...
#Scheme
Scheme
sash[r7rs]> (integer? 1) #t sash[r7rs]> (integer? 2/3) #f sash[r7rs]> (integer? 4/2) #t sash[r7rs]> (integer? 1+3i) #f sash[r7rs]> (integer? 1+0i) #t sash[r7rs]> (exact? 3.0) #f sash[r7rs]> (integer? 3.0) #t sash[r7rs]> (integer? 3.5) #f sash[r7rs]> (integer? 1.23e3) #t sash[r7rs]> (integer? 1.23e1) #f sash[r7rs]> (int...
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 ...
#Raku
Raku
my %licenses;   %licenses<count max> = 0,0;   for $*IN.lines -> $line { my ( $license, $date_time ); ( *, $license, *, $date_time ) = split /\s+/, $line; if $license eq 'OUT' { %licenses<count>++; if %licenses<count> > %licenses<max> { %licenses<max> = %licenses<count>; ...
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.
#Perl
Perl
# ptest.t use strict; use warnings;   use Test;   my %tests; BEGIN { # plan tests before loading Palindrome.pm %tests = ( 'A man, a plan, a canal: Panama.' => 1, 'My dog has fleas' => 0, "Madam, I'm Adam." => 1, '1 on 1'...
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...
#Crystal
Crystal
days = "first second third fourth fifth sixth seventh eighth ninth tenth eleventh twelfth".split " " gifts = "A partridge in a pear tree Two turtle doves and 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 Ele...
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#Retro
Retro
-3 5 out wait 5 in !cw -4 5 out wait 5 in !ch
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#REXX
REXX
width = 'tput'( 'cols' ) height = 'tput'( 'lines' )   say 'The terminal is' width 'characters wide' say 'and has' height 'lines'
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#Ring
Ring
  system("mode 50,20")  
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#Ruby
Ruby
def winsize # Ruby 1.9.3 added 'io/console' to the standard library. require 'io/console' IO.console.winsize rescue LoadError # This works with older Ruby, but only with systems # that have a tput(1) command, such as Unix clones. [Integer(`tput li`), Integer(`tput co`)] end   rows, cols = winsize printf "%d...
http://rosettacode.org/wiki/Terminal_control/Coloured_text
Terminal control/Coloured text
Task Display a word in various colours on the terminal. The system palette, or colours such as Red, Green, Blue, Magenta, Cyan, and Yellow can be used. Optionally demonstrate: How the system should determine if the terminal supports colour Setting of the background colour How to cause blinking or flashing (if ...
#C.23
C#
  static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Red; Console.BackgroundColor = ConsoleColor.Yellow; Console.WriteLine("Red on Yellow"); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.Black; Console.WriteLine("White on black"); ...
http://rosettacode.org/wiki/Terminal_control/Coloured_text
Terminal control/Coloured text
Task Display a word in various colours on the terminal. The system palette, or colours such as Red, Green, Blue, Magenta, Cyan, and Yellow can be used. Optionally demonstrate: How the system should determine if the terminal supports colour Setting of the background colour How to cause blinking or flashing (if ...
#COBOL
COBOL
*> Apologies for the repetitiveness. IDENTIFICATION DIVISION. PROGRAM-ID. coloured-text.   DATA DIVISION. WORKING-STORAGE SECTION. 78 example-str VALUE "COBOL".   01 fore-colour PIC 9. 01 back-colour PIC 9.   01 line-num PIC 99 VALUE 1. 01 col-num ...
http://rosettacode.org/wiki/Terminal_control/Cursor_movement
Terminal control/Cursor movement
Task Demonstrate how to achieve movement of the terminal cursor: how to move the cursor one position to the left how to move the cursor one position to the right how to move the cursor up one line (without affecting its horizontal position) how to move the cursor down one line (without affecting its horizontal po...
#Forth
Forth
( ANSI terminal control lexicon ) DECIMAL   ( support routines) 27 CONSTANT ESC : <##> ( n -- ) ( sends n, radix 10, no spaces) BASE @ >R DECIMAL 0 <# #S #> TYPE R> BASE ! ;   : ESC[ ( -- ) ESC EMIT ." [" ;   ( ANSI terminal commands as Forth words) : <CUU> ( row --) ESC[ <##> ." A" ; : <CUD> ( r...
http://rosettacode.org/wiki/Terminal_control/Cursor_movement
Terminal control/Cursor movement
Task Demonstrate how to achieve movement of the terminal cursor: how to move the cursor one position to the left how to move the cursor one position to the right how to move the cursor up one line (without affecting its horizontal position) how to move the cursor down one line (without affecting its horizontal po...
#Go
Go
package main   import ( "fmt" "time" "os" "os/exec" "strconv" )   func main() { tput("clear") // clear screen tput("cup", "6", "3") // an initial position time.Sleep(1 * time.Second) tput("cub1") // left time.Sleep(1 * time.Second) tput("cuf1") // right time.Sleep(1 * tim...
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#Python
Python
print("\033[6;3HHello")
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#Quackery
Quackery
[ number$ swap number$ $ 'print("\033[' rot join char ; join swap join $ 'H", end="")' join python ] is cursor-at ( x y --> )   3 6 cursor-at say "Hello"
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#Racket
Racket
  #lang racket (require (planet neil/charterm:3:0)) (with-charterm (charterm-clear-screen) (charterm-cursor 3 6) (displayln "Hello World"))  
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#Raku
Raku
print "\e[6;3H"; print 'Hello';
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#Retro
Retro
with console' : hello 3 6 at-xy "Hello" puts ;
http://rosettacode.org/wiki/Tau_number
Tau number
A Tau number is a positive integer divisible by the count of its positive divisors. Task Show the first   100   Tau numbers. The numbers shall be generated during run-time (i.e. the code may not contain string literals, sets/arrays of integers, or alike). Related task  Tau function
#Action.21
Action!
CARD FUNC DivisorCount(CARD n) CARD result,p,count   result=1 WHILE (n&1)=0 DO result==+1 n=n RSH 1 OD   p=3 WHILE p*p<=n DO count=1 WHILE n MOD p=0 DO count==+1 n==/p OD result==*count p==+2 OD   IF n>1 THEN result==*2 FI RETURN (result)   PROC Main...
http://rosettacode.org/wiki/Tau_number
Tau number
A Tau number is a positive integer divisible by the count of its positive divisors. Task Show the first   100   Tau numbers. The numbers shall be generated during run-time (i.e. the code may not contain string literals, sets/arrays of integers, or alike). Related task  Tau function
#ALGOL_68
ALGOL 68
BEGIN # find tau numbers - numbers divisible by the count of theoir divisors # # calculates the number of divisors of v # PROC divisor count = ( INT v )INT: BEGIN INT total := 1, n := v; # Deal with powers of 2 first # WHILE NOT ODD n ...
http://rosettacode.org/wiki/Teacup_rim_text
Teacup rim text
On a set of coasters we have, there's a picture of a teacup.   On the rim of the teacup the word   TEA   appears a number of times separated by bullet characters   (•). It occurred to me that if the bullet were removed and the words run together,   you could start at any letter and still end up with a meaningful three...
#BaCon
BaCon
OPTION COLLAPSE TRUE   dict$ = LOAD$(DIRNAME$(ME$) & "/unixdict.txt")   FOR word$ IN dict$ STEP NL$ IF LEN(word$) = 3 AND AMOUNT(UNIQ$(EXPLODE$(word$, 1))) = 3 THEN domain$ = APPEND$(domain$, 0, word$) NEXT   FOR w1$ IN domain$ w2$ = RIGHT$(w1$, 2) & LEFT$(w1$, 1) w3$ = RIGHT$(w2$, 2) & LEFT$(w2$, 1) IF...
http://rosettacode.org/wiki/Teacup_rim_text
Teacup rim text
On a set of coasters we have, there's a picture of a teacup.   On the rim of the teacup the word   TEA   appears a number of times separated by bullet characters   (•). It occurred to me that if the bullet were removed and the words run together,   you could start at any letter and still end up with a meaningful three...
#C
C
#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <glib.h>   int string_compare(gconstpointer p1, gconstpointer p2) { const char* const* s1 = p1; const char* const* s2 = p2; return strcmp(*s1, *s2); }   GPtrArray* load_dictionary(const char* file, GError** error_ptr) { GError* error =...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#11l
11l
V k = 21.0 print(‘K ’k) print(‘C ’(k - 273.15)) print(‘F ’(k * 1.8 - 459.67)) print(‘R ’(k * 1.8))
http://rosettacode.org/wiki/Tau_function
Tau function
Given a positive integer, count the number of its positive divisors. Task Show the result for the first   100   positive integers. Related task  Tau number
#11l
11l
F tau(n) V ans = 0 V i = 1 V j = 1 L i * i <= n I 0 == n % i ans++ j = n I/ i I j != i ans++ i++ R ans   print((1..100).map(n -> tau(n)))
http://rosettacode.org/wiki/Terminal_control/Clear_the_screen
Terminal control/Clear the screen
Task Clear the terminal window.
#ALGOL_68
ALGOL 68
curses start; # needed before any screen clearing, positioning etc. # curses clear # clear the screen #
http://rosettacode.org/wiki/Terminal_control/Clear_the_screen
Terminal control/Clear the screen
Task Clear the terminal window.
#ARM_Assembly
ARM Assembly
    /* ARM assembly Raspberry PI */ /* program clearScreen.s */   /* Constantes */ .equ STDOUT, 1 @ Linux output console .equ EXIT, 1 @ Linux syscall .equ WRITE, 4 @ Linux syscall   .equ BUFFERSIZE, 100   /* Initialized dat...
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...
#Erlang
Erlang
% Implemented by Arjun Sunel -module(ternary). -export([main/0, nott/1, andd/2,orr/2, then/2, equiv/2]).   main() -> {ok, [A]} = io:fread("Enter A: ","~s"), {ok, [B]} = io:fread("Enter B: ","~s"), andd(A,B).   nott(S) -> if S=="T" -> io : format("F\n");   S=="F" -> io : format("T\n");   true -> io:...
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...
#Fortran
Fortran
  Crunches a set of hourly data. Starts with a date, then 24 pairs of value,indicator for that day, on one line. INTEGER Y,M,D !Year, month, and day. INTEGER GOOD(24) !The indicators. REAL*8 V(24),VTOT,T !The grist. INTEGER NV,N,NB !Number of good values overall, and in a day. INTEGER I...
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...
#Racket
Racket
#lang racket ;; Imperative version: Translation of C ;; Vigenère: Translation of Pascal (module+ test (require tests/eli-tester))   ;; --------------------------------------------------------------------------------------------------- ;; standard.h: Standard definitions and types, Bob Jenkins (define UB4MAXVA...
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...
#Sidef
Sidef
func is_int (n, tolerance=0) {  !!(abs(n.real.round + n.imag - n) <= tolerance) }   %w(25.000000 24.999999 25.000100 -2.1e120 -5e-2 Inf NaN 5.0+0.0i 5-5i).each {|s| var n = Number(s) printf("%-10s  %-8s  %-5s\n", s, is_int(n), is_int(n, tolerance: 0.00001)) }
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...
#Tcl
Tcl
proc isNumberIntegral {x} { expr {$x == entier($x)} } # test with various kinds of numbers: foreach x {1e100 3.14 7 1.000000000000001 1000000000000000000000 -22.7 -123.000} { puts [format "%s: %s" $x [expr {[isNumberIntegral $x] ? "yes" : "no"}]] }
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 ...
#REXX
REXX
/*REXX program processes instrument data as read from a time sorted data file.*/ iFID= 'LICENSE.LOG' /*the fileID of the input file. */ high=0 /*highest number of licenses (so far). */ #=0 /*the count of number of licenses out....
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.
#Phix
Phix
with javascript_semantics requires("0.8.2") function is_palindrome(sequence s) return s==reverse(s) end function --set_test_verbosity(TEST_QUIET) -- default, no output when third call removed --set_test_verbosity(TEST_SUMMARY) -- first and last line only [w or w/o ""] --set_test_verb...
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.
#PicoLisp
PicoLisp
(de palindrome? (S) (= (setq S (chop S)) (reverse S)) )   (test T (palindrome? "racecar")) (test NIL (palindrome? "ferrari"))
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...
#D
D
immutable 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 drumming";   immutable days = "first second third fourth fif...
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#Scala
Scala
/* First execute the terminal command: 'export COLUMNS LINES' before running this program for it to work (returned 'null' sizes otherwise). */   val (lines, columns) = (System.getenv("LINES"), System.getenv("COLUMNS")) println(s"Lines = $lines, Columns = $columns")
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#Seed7
Seed7
$ include "seed7_05.s7i"; include "console.s7i";   const proc: main is func local var text: console is STD_NULL; begin console := open(CONSOLE); writeln(console, "height: " <& height(console) lpad 3); writeln(console, "width: " <& width(console) lpad 3); # Terminal windows often restore the p...
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#Sidef
Sidef
var stty = `stty -a`; var lines = stty.match(/\brows\h+(\d+)/); var cols = stty.match(/\bcolumns\h+(\d+)/); say "#{lines} #{cols}";
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#Tcl
Tcl
set width [exec tput cols] set height [exec tput lines] puts "The terminal is $width characters wide and has $height lines"
http://rosettacode.org/wiki/Terminal_control/Coloured_text
Terminal control/Coloured text
Task Display a word in various colours on the terminal. The system palette, or colours such as Red, Green, Blue, Magenta, Cyan, and Yellow can be used. Optionally demonstrate: How the system should determine if the terminal supports colour Setting of the background colour How to cause blinking or flashing (if ...
#Common_Lisp
Common Lisp
(defun coloured-text () (with-screen (scr :input-blocking t :input-echoing nil :cursor-visible nil) (dolist (i '(:red :green :yellow :blue :magenta :cyan :white)) (add-string scr (format nil "~A~%" i) :fgcolor i)) (refresh scr) ;; wait for keypress (get-char scr)))
http://rosettacode.org/wiki/Terminal_control/Coloured_text
Terminal control/Coloured text
Task Display a word in various colours on the terminal. The system palette, or colours such as Red, Green, Blue, Magenta, Cyan, and Yellow can be used. Optionally demonstrate: How the system should determine if the terminal supports colour Setting of the background colour How to cause blinking or flashing (if ...
#D
D
import std.conv, std.stdio;   enum Color { fgBlack = 30, fgRed, fgGreen, fgYellow, fgBlue, fgMagenta, fgCyan, fgWhite,   bgBlack = 40, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite }   string color(string text, Color ink) { retur...
http://rosettacode.org/wiki/Terminal_control/Cursor_movement
Terminal control/Cursor movement
Task Demonstrate how to achieve movement of the terminal cursor: how to move the cursor one position to the left how to move the cursor one position to the right how to move the cursor up one line (without affecting its horizontal position) how to move the cursor down one line (without affecting its horizontal po...
#Julia
Julia
const ESC = "\u001B" # escape code const moves = Dict( "left" => "[1D", "right" => "[1C", "up" => "[1A", "down" => "[1B", "linestart" => "[9D", "topleft" => "[H", "bottomright" => "[24;79H")   print("$ESC[2J") # clear terminal first print("$ESC[10;10H") # move cursor to (10, 10) say const count ...
http://rosettacode.org/wiki/Terminal_control/Cursor_movement
Terminal control/Cursor movement
Task Demonstrate how to achieve movement of the terminal cursor: how to move the cursor one position to the left how to move the cursor one position to the right how to move the cursor up one line (without affecting its horizontal position) how to move the cursor down one line (without affecting its horizontal po...
#Kotlin
Kotlin
// version 1.1.2   const val ESC = "\u001B" // escape code   fun main(args: Array<String>) { print("$ESC[2J") // clear terminal first print("$ESC[10;10H") // move cursor to (10, 10) say val aecs = arrayOf( "[1D", // left "[1C", // right "[1A", // up "[1B", //...
http://rosettacode.org/wiki/Terminal_control/Cursor_movement
Terminal control/Cursor movement
Task Demonstrate how to achieve movement of the terminal cursor: how to move the cursor one position to the left how to move the cursor one position to the right how to move the cursor up one line (without affecting its horizontal position) how to move the cursor down one line (without affecting its horizontal po...
#Lasso
Lasso
#!/usr/bin/lasso9   local(esc = decode_base64('Gw=='))   stdoutnl('Demonstrate how to move the cursor one position to the left Demonstrate how to move the cursor one position to the right Demonstrate how to move the cursor up one line (without affecting its horizontal position) Demonstrate how to move the cursor down ...
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#REXX
REXX
/*REXX program demonstrates moving the cursor position and writing of text to same place*/   call cursor 3,6 /*move the cursor to row 3, column 6. */ say 'Hello' /*write the text at that location. */       call scrwrite 30,50,'Hello.' ...
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#Ring
Ring
  # Project : Terminal control/Cursor positioning   for n = 1 to 5 see nl next see " Hello"  
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#Ruby
Ruby
require 'curses'   Curses.init_screen begin Curses.setpos(6, 3) # column 6, row 3 Curses.addstr("Hello")   Curses.getch # Wait until user presses some key. ensure Curses.close_screen end
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#Scala
Scala
object Main extends App { print("\u001Bc") // clear screen first println("\u001B[6;3HHello") }
http://rosettacode.org/wiki/Taxicab_numbers
Taxicab numbers
A   taxicab number   (the definition that is being used here)   is a positive integer that can be expressed as the sum of two positive cubes in more than one way. The first taxicab number is   1729,   which is: 13   +   123       and also 93   +   103. Taxicab numbers are also known as:   taxi numbers   tax...
#11l
11l
V cubes = (1..1199).map(x -> Int64(x) ^ 3) [Int64 = Int64] crev L(x3) cubes crev[x3] = L.index + 1   V sums = sorted(multiloop_filtered(cubes, cubes, (x, y) -> y < x, (x, y) -> x + y))   V idx = 0 L(i) 1 .< sums.len - 1 I sums[i - 1] != sums[i] & sums[i] == sums[i + 1] idx++ I (idx > 25 & idx < 2000) ...
http://rosettacode.org/wiki/Tau_number
Tau number
A Tau number is a positive integer divisible by the count of its positive divisors. Task Show the first   100   Tau numbers. The numbers shall be generated during run-time (i.e. the code may not contain string literals, sets/arrays of integers, or alike). Related task  Tau function
#ALGOL-M
ALGOL-M
begin   integer array dcount[1:1100]; integer i, j, n;   integer function mod(a,b); integer a,b; mod := a-a/b*b;   % Calculate counts of divisors for 1 .. 1100 % for i := 1 step 1 until 1100 do dcount[i] := 1; for i := 2 step 1 until 1100 do begin j := i; while j <= 1100 do begin dcount[j] := dcount...
http://rosettacode.org/wiki/Tau_number
Tau number
A Tau number is a positive integer divisible by the count of its positive divisors. Task Show the first   100   Tau numbers. The numbers shall be generated during run-time (i.e. the code may not contain string literals, sets/arrays of integers, or alike). Related task  Tau function
#APL
APL
(⊢(/⍨)(0=(0+.=⍳|⊢)|⊢)¨)⍳ 1096
http://rosettacode.org/wiki/Tau_number
Tau number
A Tau number is a positive integer divisible by the count of its positive divisors. Task Show the first   100   Tau numbers. The numbers shall be generated during run-time (i.e. the code may not contain string literals, sets/arrays of integers, or alike). Related task  Tau function
#AppleScript
AppleScript
on factorCount(n) if (n < 1) then return 0 set counter to 2 set sqrt to n ^ 0.5 if (sqrt mod 1 = 0) then set counter to 1 repeat with i from (sqrt div 1) to 2 by -1 if (n mod i = 0) then set counter to counter + 2 end repeat   return counter end factorCount   -- Task code: local outp...
http://rosettacode.org/wiki/Teacup_rim_text
Teacup rim text
On a set of coasters we have, there's a picture of a teacup.   On the rim of the teacup the word   TEA   appears a number of times separated by bullet characters   (•). It occurred to me that if the bullet were removed and the words run together,   you could start at any letter and still end up with a meaningful three...
#C.2B.2B
C++
#include <algorithm> #include <fstream> #include <iostream> #include <set> #include <string> #include <vector>   // filename is expected to contain one lowercase word per line std::set<std::string> load_dictionary(const std::string& filename) { std::ifstream in(filename); if (!in) throw std::runtime_err...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#360_Assembly
360 Assembly
* Temperature conversion 10/09/2015 TEMPERAT CSECT USING TEMPERAT,R15 LA R4,1 i=1 LA R5,TT @tt(1) LA R6,IDE @ide(1) LOOPI CH R4,=AL2((T-TT)/8) do i=1 to hbound(tt) BH ELOOPI ZAP T,0(8,R5) ...
http://rosettacode.org/wiki/Tau_function
Tau function
Given a positive integer, count the number of its positive divisors. Task Show the result for the first   100   positive integers. Related task  Tau number
#AArch64_Assembly
AArch64 Assembly
  /* ARM assembly AARCH64 Raspberry PI 3B or android 64 bits */ /* program taufunction64.s */   /*******************************************/ /* Constantes file */ /*******************************************/ /* for this file see task include a file in language AArch64 assembly*/ .include "....
http://rosettacode.org/wiki/Tau_function
Tau function
Given a positive integer, count the number of its positive divisors. Task Show the result for the first   100   positive integers. Related task  Tau number
#Action.21
Action!
CARD FUNC DivisorCount(CARD n) CARD result,p,count   result=1 WHILE (n&1)=0 DO result==+1 n=n RSH 1 OD   p=3 WHILE p*p<=n DO count=1 WHILE n MOD p=0 DO count==+1 n==/p OD result==*count p==+2 OD   IF n>1 THEN result==*2 FI RETURN (result)   PROC Main...
http://rosettacode.org/wiki/Tau_function
Tau function
Given a positive integer, count the number of its positive divisors. Task Show the result for the first   100   positive integers. Related task  Tau number
#ALGOL_68
ALGOL 68
BEGIN # find the count of the divisors of the first 100 positive integers # # calculates the number of divisors of v # PROC divisor count = ( INT v )INT: BEGIN INT total := 1, n := v; # Deal with powers of 2 first # WHILE NOT ODD n DO...
http://rosettacode.org/wiki/Terminal_control/Clear_the_screen
Terminal control/Clear the screen
Task Clear the terminal window.
#Arturo
Arturo
clear
http://rosettacode.org/wiki/Terminal_control/Clear_the_screen
Terminal control/Clear the screen
Task Clear the terminal window.
#AutoHotkey
AutoHotkey
RunWait %comspec% /c cls
http://rosettacode.org/wiki/Terminal_control/Clear_the_screen
Terminal control/Clear the screen
Task Clear the terminal window.
#AWK
AWK
system("clear")
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...
#Factor
Factor
! rosettacode/ternary/ternary.factor ! http://rosettacode.org/wiki/Ternary_logic USING: combinators kernel ; IN: rosettacode.ternary   SINGLETON: m UNION: trit t m POSTPONE: f ;   GENERIC: >trit ( object -- trit ) M: trit >trit ;   : tnot ( trit1 -- trit ) >trit { { t [ f ] } { m [ m ] } { f [ t ] } } case ;   : ta...
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...
#Go
Go
package main   import ( "bufio" "fmt" "log" "os" "strconv" "strings" )   const ( filename = "readings.txt" readings = 24 // per line fields = readings*2 + 1 // per line )   func main() { file, err := os.Open(filename) if err != nil { log.Fatal(err) } defer file.Close() var ( badRun, maxR...
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...
#Raku
Raku
my uint32 (@mm, @randrsl, $randcnt, $aa, $bb, $cc); my \ϕ := 2654435769; constant MOD = 95; constant START = 32;   constant MAXINT = uint.Range.max; enum CipherMode < ENCIPHER DECIPHER NONE >;   sub mix (\n) { sub mix1 (\i, \v) { n[i] +^= v; n[(i+3)%8] += n[i]; n[(i+1)%8] += n[(i+2)%8]; } ...
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...
#Wren
Wren
import "/big" for BigRat import "/complex" for Complex import "/rat" for Rat import "/fmt" for Fmt   var tests1 = [25.000000, 24.999999, 25.000100] var tests2 = ["-2.1e120"] var tests3 = [-5e-2, 0/0, 1/0] var tests4 = [Complex.fromString("5.0+0.0i"), Complex.fromString("5-5i")] var tests5 = [Rat.new(24, 8), Rat.new(-5,...
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 ...
#Ruby
Ruby
out = 0 max_out = -1 max_times = []   File.foreach('mlijobs.txt') do |line| out += line.include?("OUT") ? 1 : -1 if out > max_out max_out = out max_times = [] end max_times << line.split[3] if out == max_out end   puts "Maximum simultaneous license use is #{max_out} at the following times:" max_times.e...
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 ...
#Run_BASIC
Run BASIC
open "c:\data\temp\logFile.txt" for input as #f while not(eof(#f)) line input #f, a$ if word$(a$,2," ") = "IN" then count = count - 1 else count = count + 1 maxCount = max(maxCount,count) wend open "c:\data\temp\logFile.txt" for input as #f while not(eof(#f)) line input #f, a$ if word$(a$,2," ") = "IN" then c...
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.
#Prolog
Prolog
palindrome(Word) :- name(Word,List), reverse(List,List).   :- begin_tests(palindrome).   test(valid_palindrome) :- palindrome('ingirumimusnocteetconsumimurigni'). test(invalid_palindrome, [fail]) :- palindrome('this is not a palindrome').   :- end_tests(palindrome).
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.
#PureBasic
PureBasic
Macro DoubleQuote ; Needed for the Assert-Macro below "  ; " second dlbquote to prevent Rosettas misshighlighting of following code. Remove comment before execution! EndMacro Macro Assert(TEST,MSG="") CompilerIf #PB_Compiler_Debugger If Not (TEST) If MSG<>"": Debug MSG: EndIf ...
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...
#dc
dc
0   d [first] r :n d [A partridge in a pear tree.] r :g 1 +   d [second] r :n d [Two turtle doves and] r :g 1 +   d [third] r :n d [Three French hens,] r :g 1 +   d [fourth] r :n d [Four calling birds,] r...
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...
#Dyalect
Dyalect
let days = [ "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth" ] let gifts = [ "A partridge in a pear tree", "Two turtle doves", "Three french hens", "Four calling birds", "Five golden rings", "Six geese a-laying", "S...
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#UNIX_Shell
UNIX Shell
#!/bin/sh WIDTH=`tput cols` HEIGHT=`tput lines` echo "The terminal is $WIDTH characters wide and has $HEIGHT lines."
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#Visual_Basic
Visual Basic
Module Module1   Sub Main() Dim bufferHeight = Console.BufferHeight Dim bufferWidth = Console.BufferWidth Dim windowHeight = Console.WindowHeight Dim windowWidth = Console.WindowWidth   Console.Write("Buffer Height: ") Console.WriteLine(bufferHeight) Console.W...
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#Wren
Wren
/* terminal_control_dimensions.wren */   class C { foreign static terminalWidth foreign static terminalHeight }   var w = C.terminalWidth var h = C.terminalHeight System.print("The dimensions of the terminal are:") System.print(" Width = %(w)") System.print(" Height = %(h)")
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#XPL0
XPL0
include c:\cxpl\codes; int W, H; [W:= Peek($40, $4A); \IBM-PC BIOS data H:= Peek($40, $84) + 1; Text(0, "Terminal width and height = "); IntOut(0, W); ChOut(0, ^x); IntOut(0, H); ]
http://rosettacode.org/wiki/Terminal_control/Dimensions
Terminal control/Dimensions
Determine the height and width of the terminal, and store this information into variables for subsequent use.
#Yabasic
Yabasic
clear screen w = peek("screenwidth") h = peek("screenheight") print "Informaci¢n sobre el escritorio (terminal):" print " Ancho de la terminal: ", w, " (pixel)" print "Altura de la terminal: ", h, " (pixel)"   open window 640,480 w = peek("winheight") h = peek("winwidth") print "\n\nInformaci¢n sobre el modo gr fico:" ...
http://rosettacode.org/wiki/Terminal_control/Coloured_text
Terminal control/Coloured text
Task Display a word in various colours on the terminal. The system palette, or colours such as Red, Green, Blue, Magenta, Cyan, and Yellow can be used. Optionally demonstrate: How the system should determine if the terminal supports colour Setting of the background colour How to cause blinking or flashing (if ...
#Dc
Dc
## after PARI/GP   # C: for( initcode ; condcode ; incrcode ) {body} # .[q] [1] [2] [3] [4] # # [initcode] [condcode] [incrcode] [body] (for) [ [q]S. 4:.3:.2:.x [2;.x 0=. 4;.x 3;.x 0;.x]d0:.x Os.L.o ]sF # F = for   [ 27P ...
http://rosettacode.org/wiki/Terminal_control/Coloured_text
Terminal control/Coloured text
Task Display a word in various colours on the terminal. The system palette, or colours such as Red, Green, Blue, Magenta, Cyan, and Yellow can be used. Optionally demonstrate: How the system should determine if the terminal supports colour Setting of the background colour How to cause blinking or flashing (if ...
#F.23
F#
open System   Console.ForegroundColor <- ConsoleColor.Red Console.BackgroundColor <- ConsoleColor.Yellow Console.WriteLine("Red on Yellow")   Console.ForegroundColor <- ConsoleColor.White Console.BackgroundColor <- ConsoleColor.Black Console.WriteLine("White on Black")   Console.ForegroundColor <- ConsoleColor.Green Co...
http://rosettacode.org/wiki/Terminal_control/Coloured_text
Terminal control/Coloured text
Task Display a word in various colours on the terminal. The system palette, or colours such as Red, Green, Blue, Magenta, Cyan, and Yellow can be used. Optionally demonstrate: How the system should determine if the terminal supports colour Setting of the background colour How to cause blinking or flashing (if ...
#Forth
Forth
( ANSI terminal control lexicon Colored Text) DECIMAL ( support routines) 27 CONSTANT ESC : <##> ( n -- ) ( sends n, radix 10, no spaces) BASE @ >R 0 <# #S #> TYPE R> BASE ! ;   : ESC[ ( -- ) ESC EMIT ." [" ; ( Attributes ) 1 CONSTANT BOLD 2 CONSTANT DIM 3 CONSTANT ITALIC 5 CONSTANT BLINK ...
http://rosettacode.org/wiki/Terminal_control/Cursor_movement
Terminal control/Cursor movement
Task Demonstrate how to achieve movement of the terminal cursor: how to move the cursor one position to the left how to move the cursor one position to the right how to move the cursor up one line (without affecting its horizontal position) how to move the cursor down one line (without affecting its horizontal po...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
Run["tput cub1"] (* one position to the left *) Run["tput cuf1" ] (* one position to the right *) Run["tput cuu1" ] (* up one line *) Run["tput cud1"] (* down one line *) Run["tput cr"] (* beginning of line *) Run["tput home"] ...
http://rosettacode.org/wiki/Terminal_control/Cursor_movement
Terminal control/Cursor movement
Task Demonstrate how to achieve movement of the terminal cursor: how to move the cursor one position to the left how to move the cursor one position to the right how to move the cursor up one line (without affecting its horizontal position) how to move the cursor down one line (without affecting its horizontal po...
#Nim
Nim
import terminal   echo "Press the return key to go to next step." echo "Starting in the middle of last line."   template waitUser() = while getch() != '\r': discard   let (width, height) = terminalSize() # Start by positionning the cursor in the middle of the line. setCursorXPos(width div 2) waitUser() # Move one cha...
http://rosettacode.org/wiki/Terminal_control/Cursor_movement
Terminal control/Cursor movement
Task Demonstrate how to achieve movement of the terminal cursor: how to move the cursor one position to the left how to move the cursor one position to the right how to move the cursor up one line (without affecting its horizontal position) how to move the cursor down one line (without affecting its horizontal po...
#Perl
Perl
system "tput cub1"; sleep 1; # one position to the left system "tput cuf1"; sleep 1; # one position to the right system "tput cuu1"; sleep 1; # up one line system "tput cud1"; sleep 1; # down one line system "tput cr"; sleep 1; # beginning of line system "tput home"; sleep 1; # top left corner   $_ = qx[stty -a...
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#Seed7
Seed7
$ include "seed7_05.s7i"; include "console.s7i";   const proc: main is func local var text: console is STD_NULL; begin console := open(CONSOLE); setPos(console, 6, 3); write(console, "Hello"); # Terminal windows often restore the previous # content, when a program is terminated. Therefore ...
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#Tcl
Tcl
exec tput cup 5 2 >/dev/tty puts "Hello"
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#UNIX_Shell
UNIX Shell
# The tput utility numbers from zero, so we have subtracted 1 from row and column # number to obtain correct positioning. tput cup 5 2
http://rosettacode.org/wiki/Terminal_control/Cursor_positioning
Terminal control/Cursor positioning
Task Move the cursor to column   3,   row   6,   and display the word   "Hello"   (without the quotes),   so that the letter   H   is in column   3   on row   6.
#Whitespace
Whitespace