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/Happy_numbers
Happy numbers
From Wikipedia, the free encyclopedia: A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals   1   (where it will stay),   or it loops endlessly in a cycle which does not inclu...
#ActionScript
ActionScript
function sumOfSquares(n:uint) { var sum:uint = 0; while(n != 0) { sum += (n%10)*(n%10); n /= 10; } return sum; } function isInArray(n:uint, array:Array) { for(var k = 0; k < array.length; k++) if(n == array[k]) return true; return false; } function isHappy(n) { var sequence:Array = new Array(); while(n !...
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#Raku
Raku
signal(SIGINT).tap: { note "Took { now - INIT now } seconds."; exit; }   for 0, 1, *+* ... * { sleep 0.5; .say; }
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#REXX
REXX
/*REXX program displays integers until a Ctrl─C is pressed, then shows the number of */ /*────────────────────────────────── seconds that have elapsed since start of execution.*/ call time 'Reset' /*reset the REXX elapsed timer. */ signal on halt ...
http://rosettacode.org/wiki/Hash_join
Hash join
An inner join is an operation that combines two data tables into one table, based on matching column values. The simplest way of implementing this operation is the nested loop join algorithm, but a more scalable alternative is the hash join algorithm. Task[edit] Implement the "hash join" algorithm, and demonstrate tha...
#Sidef
Sidef
func hashJoin(table1, index1, table2, index2) { var a = [] var h = Hash()   # hash phase table1.each { |s| h{s[index1]} := [] << s }   # join phase table2.each { |r| a += h{r[index2]}.map{[_,r]} }   return a }   var t1 = [[27, "Jonah"], [18, "Alan"], ...
http://rosettacode.org/wiki/Haversine_formula
Haversine formula
This page uses content from Wikipedia. The original article was at Haversine formula. 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) The haversine formula is an equation important in navigation, g...
#D
D
import std.stdio, std.math;   real haversineDistance(in real dth1, in real dph1, in real dth2, in real dph2) pure nothrow @nogc { enum real R = 6371; enum real TO_RAD = PI / 180;   alias imr = immutable real; imr ph1d = dph1 - dph2; imr ph1 = ph1d * TO_RAD; imr th1 = dth1 ...
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#Limbo
Limbo
implement HelloWorld;   include "sys.m"; sys: Sys; include "draw.m";   HelloWorld: module { init: fn(nil: ref Draw->Context, nil: list of string); };   init(nil: ref Draw->Context, nil: list of string) { sys = load Sys Sys->PATH; sys->print("Goodbye, World!"); # No automatic newline. }
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#LLVM
LLVM
; This is not strictly LLVM, as it uses the C library function "printf". ; LLVM does not provide a way to print values, so the alternative would be ; to just load the string into memory, and that would be boring.   $"OUTPUT_STR" = comdat any @"OUTPUT_STR" = linkonce_odr unnamed_addr constant [16 x i8] c"Goodbye, World!...
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#Emacs_Lisp
Emacs Lisp
(message "Hello world!")
http://rosettacode.org/wiki/Hash_from_two_arrays
Hash from two arrays
Task Using two Arrays of equal length, create a Hash object where the elements from one array (the keys) are linked to the elements of the other (the values) Related task   Associative arrays/Creation
#LiveCode
LiveCode
put "a,b,c" into list1 put 10,20,30 into list2 split list1 using comma split list2 using comma repeat with i=1 to the number of elements of list1 put list2[i] into list3[list1[i]] end repeat combine list3 using comma and colon put list3   -- ouput -- a:10,b:20,c:30
http://rosettacode.org/wiki/Harshad_or_Niven_series
Harshad or Niven series
The Harshad or Niven numbers are positive integers ≥ 1 that are divisible by the sum of their digits. For example,   42   is a Harshad number as   42   is divisible by   (4 + 2)   without remainder. Assume that the series is defined as the numbers in increasing order. Task The task is to create a function/method/...
#F.23
F#
let divides d n = match bigint.DivRem(n, d) with | (_, rest) -> rest = 0I   let splitToInt (str:string) = List.init str.Length (fun i -> ((int str.[i]) - (int "0".[0])))   let harshads = let rec loop n = seq { let sum = List.fold (+) 0 (splitToInt (n.ToString())) if divides (bigint sum) n t...
http://rosettacode.org/wiki/Hello_world/Newbie
Hello world/Newbie
Task Guide a new user of a language through the steps necessary to install the programming language and selection of a text editor if needed, to run the languages' example in the Hello world/Text task. Assume the language-newbie is a programmer in another language. Assume the language-newbie is competent in install...
#zkl
zkl
Extract to ~ Open a termninal
http://rosettacode.org/wiki/Hello_world/Newbie
Hello world/Newbie
Task Guide a new user of a language through the steps necessary to install the programming language and selection of a text editor if needed, to run the languages' example in the Hello world/Text task. Assume the language-newbie is a programmer in another language. Assume the language-newbie is competent in install...
#Zoomscript
Zoomscript
10 PRINT "Hello"
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#PureBasic
PureBasic
If OpenWindow(0, 0, 0, 5, 5, "", #PB_Window_Maximize + #PB_Window_Invisible) maxX = WindowWidth(0) maxY = WindowHeight(0) CloseWindow(0) MessageRequester("Result", "Maximum Window Width: " + Str(maxX) + ", Maximum Window Height: " + Str(maxY)) EndIf
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#Python
Python
  #!/usr/bin/env python3   import tkinter as tk # import the module.   root = tk.Tk() # Create an instance of the class. root.state('zoomed') # Maximized the window. root.update_idletasks() # Update the display. tk.Label(root, text=(str(root.winfo_width())+ " x " +str(root.winfo_height())), font=("Helvetica", ...
http://rosettacode.org/wiki/Hello_world/Graphical
Hello world/Graphical
Task Display the string       Goodbye, World!       on a GUI object   (alert box, plain window, text area, etc.). Related task   Hello world/Text
#C.2B.2B.2FCLI
C++/CLI
  using namespace System::Windows::Forms;   int main(array<System::String^> ^args) { MessageBox::Show("Goodbye, World!", "Rosetta Code"); return 0; }  
http://rosettacode.org/wiki/GUI_enabling/disabling_of_controls
GUI enabling/disabling of controls
In addition to fundamental GUI component interaction, an application should dynamically enable and disable GUI components, to give some guidance to the user, and prohibit (inter)actions which are inappropriate in the current state of the application. Task Similar to the task GUI component interaction, write a progr...
#BBC_BASIC
BBC BASIC
INSTALL @lib$+"WINLIB2" INSTALL @lib$+"WINLIB5" ES_NUMBER = 8192   form% = FN_newdialog("Rosetta Code", 100, 100, 100, 52, 8, 1000) idInc% = FN_setproc(PROCinc) idDec% = FN_setproc(PROCdec)   PROC_static(form%, "Value:", 100, 10, 10, 24, 14, 0) PROC_editbox(form%, "0", 10...
http://rosettacode.org/wiki/Happy_numbers
Happy numbers
From Wikipedia, the free encyclopedia: A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals   1   (where it will stay),   or it loops endlessly in a cycle which does not inclu...
#Ada
Ada
with Ada.Text_IO; use Ada.Text_IO; with Ada.Containers.Ordered_Sets;   procedure Test_Happy_Digits is function Is_Happy (N : Positive) return Boolean is package Sets_Of_Positive is new Ada.Containers.Ordered_Sets (Positive); use Sets_Of_Positive; function Next (N : Positive) return Natural is ...
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#Ruby
Ruby
t1 = Time.now   catch :done do Signal.trap('INT') do Signal.trap('INT', 'DEFAULT') # reset to default throw :done end n = 0 loop do sleep(0.5) n += 1 puts n end end   tdelt = Time.now - t1 puts 'Program has run for %5.3f seconds.' % tdelt
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#Rust
Rust
  #[cfg(unix)] fn main() { use std::sync::atomic::{AtomicBool, Ordering}; use std::thread; use std::time::{Duration, Instant};   use libc::{sighandler_t, SIGINT};   // The time between ticks of our counter. let duration = Duration::from_secs(1) / 2;   // "SIGINT received" global variable. ...
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#Scala
Scala
import sun.misc.Signal import sun.misc.SignalHandler   object SignalHandl extends App { val start = System.nanoTime() var counter = 0   Signal.handle(new Signal("INT"), new SignalHandler() { def handle(sig: Signal) { println(f"\nProgram execution took ${(System.nanoTime() - start) / 1e9f}%f seconds\n") ...
http://rosettacode.org/wiki/Hash_join
Hash join
An inner join is an operation that combines two data tables into one table, based on matching column values. The simplest way of implementing this operation is the nested loop join algorithm, but a more scalable alternative is the hash join algorithm. Task[edit] Implement the "hash join" algorithm, and demonstrate tha...
#SQL
SQL
-- setting up the test data   CREATE TABLE people (age NUMBER(3), name varchar2(30)); INSERT INTO people (age, name) SELECT 27, 'Jonah' FROM dual UNION ALL SELECT 18, 'Alan' FROM dual UNION ALL SELECT 28, 'Glory' FROM dual UNION ALL SELECT 18, 'Popeye' FROM dual UNION ALL SELECT 28, 'Alan' FROM dual ;  ...
http://rosettacode.org/wiki/Haversine_formula
Haversine formula
This page uses content from Wikipedia. The original article was at Haversine formula. 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) The haversine formula is an equation important in navigation, g...
#Dart
Dart
import 'dart:math';   class Haversine { static final R = 6372.8; // In kilometers   static double haversine(double lat1, lon1, lat2, lon2) { double dLat = _toRadians(lat2 - lat1); double dLon = _toRadians(lon2 - lon1); lat1 = _toRadians(lat1); lat2 = _toRadians(lat2); double a = pow(sin(dLat / 2...
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#Logtalk
Logtalk
  :- object(error_message).   % the initialization/1 directive argument is automatically executed % when the object is compiled loaded into memory: :- initialization(write('Goodbye, World!')).   :- end_object.  
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#Lua
Lua
io.write("Goodbye, World!")
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#Emojicode
Emojicode
🏁 🍇 😀 🔤Hello world!🔤 🍉
http://rosettacode.org/wiki/Hash_from_two_arrays
Hash from two arrays
Task Using two Arrays of equal length, create a Hash object where the elements from one array (the keys) are linked to the elements of the other (the values) Related task   Associative arrays/Creation
#Lua
Lua
function(keys,values) local t = {} for i=1, #keys do t[keys[i]] = values[i] end end
http://rosettacode.org/wiki/Hash_from_two_arrays
Hash from two arrays
Task Using two Arrays of equal length, create a Hash object where the elements from one array (the keys) are linked to the elements of the other (the values) Related task   Associative arrays/Creation
#M2000_Interpreter
M2000 Interpreter
  Module CheckAll { Module CheckVectorType { Dim Keys$(4), Values(4) Keys$(0):= "one","two","three","four" Values(0):=1,2,3,4 Inventory Dict For i=0 to 3 { Append Dict, Keys$(i):=Values(i) } Print Dict("one")+Dic...
http://rosettacode.org/wiki/Harshad_or_Niven_series
Harshad or Niven series
The Harshad or Niven numbers are positive integers ≥ 1 that are divisible by the sum of their digits. For example,   42   is a Harshad number as   42   is divisible by   (4 + 2)   without remainder. Assume that the series is defined as the numbers in increasing order. Task The task is to create a function/method/...
#Factor
Factor
USING: math.text.utils lists lists.lazy ;   : niven? ( n -- ? ) dup 1 digit-groups sum mod 0 = ;   : first-n-niven ( n -- seq ) 1 lfrom [ niven? ] lfilter ltake list>array ;   : next-niven ( n -- m ) 1 + [ dup niven? ] [ 1 + ] until ;   20 first-n-niven . 1000 next-niven .
http://rosettacode.org/wiki/Hello_world/Newbie
Hello world/Newbie
Task Guide a new user of a language through the steps necessary to install the programming language and selection of a text editor if needed, to run the languages' example in the Hello world/Text task. Assume the language-newbie is a programmer in another language. Assume the language-newbie is competent in install...
#ZX_Spectrum_Basic
ZX Spectrum Basic
10 PRINT "Hello"
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#Racket
Racket
  #lang racket/gui (define-values [W H] (let ([f (new frame% [label "test"])]) (begin0 (send* f (maximize #t) (show #t) (get-client-size)) (send f show #f)))) (printf "~ax~a\n" W H)  
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#Raku
Raku
use X11::libxdo;   my $xdo = Xdo.new;   my ($dw, $dh) = $xdo.get-desktop-dimensions( 0 );   say "Desktop viewport dimensions: (maximum-fullscreen size) $dw x $dh";
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#REXX
REXX
  load "guilib.ring" new qApp { win1 = new qWidget() { new qPushButton(win1) { resize(200,200) settext("Info") setclickevent(' win1{ setwindowtitle("Width: " + width() + " Height : " + height() ) }') } ...
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#Ring
Ring
  load "guilib.ring" new qApp { win1 = new qWidget() { new qPushButton(win1) { resize(200,200) settext("Info") setclickevent(' win1{ setwindowtitle("Width: " + width() + " Height : " + height() ) }') } ...
http://rosettacode.org/wiki/Hello_world/Graphical
Hello world/Graphical
Task Display the string       Goodbye, World!       on a GUI object   (alert box, plain window, text area, etc.). Related task   Hello world/Text
#Casio_BASIC
Casio BASIC
ViewWindow 1,127,1,1,63,1 AxesOff CoordOff GridOff LabelOff
http://rosettacode.org/wiki/GUI_enabling/disabling_of_controls
GUI enabling/disabling of controls
In addition to fundamental GUI component interaction, an application should dynamically enable and disable GUI components, to give some guidance to the user, and prohibit (inter)actions which are inappropriate in the current state of the application. Task Similar to the task GUI component interaction, write a progr...
#C
C
file main.c
http://rosettacode.org/wiki/Happy_numbers
Happy numbers
From Wikipedia, the free encyclopedia: A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals   1   (where it will stay),   or it loops endlessly in a cycle which does not inclu...
#ALGOL_68
ALGOL 68
INT base10 = 10, num happy = 8;   PROC next = (INT in n)INT: ( INT n := in n; INT out := 0; WHILE n NE 0 DO out +:= ( n MOD base10 ) ** 2; n := n OVER base10 OD; out );   PROC is happy = (INT in n)BOOL: ( INT n := in n; FOR i WHILE n NE 1 AND n NE 4 DO n := next(n) OD; n=1 );   INT count := 0; F...
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#Sidef
Sidef
var start = Time.sec;   Sig.INT { |_| Sys.say("Ran for #{Time.sec - start} seconds."); Sys.exit; }   { |i| Sys.say(i); Sys.sleep(0.5); } * Math.inf;
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#Smalltalk
Smalltalk
|n|   n := 0. UserInterrupt catch:[ [true] whileTrue:[ n := n + 1. n printCR. Delay waitForSeconds: 0.5. ] ]
http://rosettacode.org/wiki/Hash_join
Hash join
An inner join is an operation that combines two data tables into one table, based on matching column values. The simplest way of implementing this operation is the nested loop join algorithm, but a more scalable alternative is the hash join algorithm. Task[edit] Implement the "hash join" algorithm, and demonstrate tha...
#Swift
Swift
func hashJoin<A, B, K: Hashable>(_ first: [(K, A)], _ second: [(K, B)]) -> [(A, K, B)] { var map = [K: [B]]()   for (key, val) in second { map[key, default: []].append(val) }   var res = [(A, K, B)]()   for (key, val) in first { guard let vals = map[key] else { continue }   res += vals.m...
http://rosettacode.org/wiki/Hash_join
Hash join
An inner join is an operation that combines two data tables into one table, based on matching column values. The simplest way of implementing this operation is the nested loop join algorithm, but a more scalable alternative is the hash join algorithm. Task[edit] Implement the "hash join" algorithm, and demonstrate tha...
#Tcl
Tcl
package require Tcl 8.6 # Only for lmap, which can be replaced with foreach   proc joinTables {tableA a tableB b} { # Optimisation: if the first table is longer, do in reverse order if {[llength $tableB] < [llength $tableA]} { return [lmap pair [joinTables $tableB $b $tableA $a] { lreverse $pair }] }...
http://rosettacode.org/wiki/Haversine_formula
Haversine formula
This page uses content from Wikipedia. The original article was at Haversine formula. 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) The haversine formula is an equation important in navigation, g...
#Delphi
Delphi
program HaversineDemo; uses Math;   function HaversineDist(th1, ph1, th2, ph2:double):double; const diameter = 2 * 6372.8; var dx, dy, dz:double; begin ph1 := degtorad(ph1 - ph2); th1 := degtorad(th1); th2 := degtorad(th2);   dz := sin(th1) - sin(th2); dx := cos(ph1) * cos(th1) - cos(th2); ...
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#m4
m4
`Goodbye, World!'dnl
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#MANOOL
MANOOL
{{extern "manool.org.18/std/0.3/all"} in Out.Write["Goodbye, World!"]}
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#Maple
Maple
  printf( "Goodbye, World!" );  
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#Erlang
Erlang
io:format("Hello world!~n").
http://rosettacode.org/wiki/Hash_from_two_arrays
Hash from two arrays
Task Using two Arrays of equal length, create a Hash object where the elements from one array (the keys) are linked to the elements of the other (the values) Related task   Associative arrays/Creation
#Maple
Maple
A := [1, 2, 3]; B := ["one", "two", three"]; T := table( zip( `=`, A, B ) );
http://rosettacode.org/wiki/Hash_from_two_arrays
Hash from two arrays
Task Using two Arrays of equal length, create a Hash object where the elements from one array (the keys) are linked to the elements of the other (the values) Related task   Associative arrays/Creation
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
Map[(Hash[Part[#, 1]] = Part[#, 2]) &, Transpose[{{1, 2, 3}, {"one", "two", "three"}}]]   ?? Hash ->Hash[1]=one ->Hash[2]=two ->Hash[3]=three
http://rosettacode.org/wiki/Harshad_or_Niven_series
Harshad or Niven series
The Harshad or Niven numbers are positive integers ≥ 1 that are divisible by the sum of their digits. For example,   42   is a Harshad number as   42   is divisible by   (4 + 2)   without remainder. Assume that the series is defined as the numbers in increasing order. Task The task is to create a function/method/...
#FBSL
FBSL
#APPTYPE CONSOLE   CLASS harshad PRIVATE: memo[]   SUB INITIALIZE() DIM i = 1, c DO IF isNiven(i) THEN c = c + 1 memo[c] = i END IF i = i + 1 IF c = 20 THEN EXIT DO LOOP memo[] = "..." i =...
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#Run_BASIC
Run BASIC
  html "<INPUT TYPE='HIDDEN' id='winHigh' name='winHigh' VALUE='";winHigh;"'></input>" html "<INPUT TYPE='HIDDEN' id='winWide' name='winWide' VALUE='";winWide;"'></input>"   html "<script> <!--   function winSize() { var myWide = 0, myHigh = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWide = window.i...
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#Scala
Scala
import java.awt.{Dimension, Insets, Toolkit}   import javax.swing.JFrame   class MaxWindowDims() extends JFrame { val toolkit: Toolkit = Toolkit.getDefaultToolkit val (insets0, screenSize) = (toolkit.getScreenInsets(getGraphicsConfiguration), toolkit.getScreenSize)   println("Physical screen size: " + screenSize...
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#Sidef
Sidef
require('Tk')   func max_window_size() -> (Number, Number) { %s'MainWindow'.new.maxsize; }   var (width, height) = max_window_size(); say (width, 'x', height);
http://rosettacode.org/wiki/Hello_world/Graphical
Hello world/Graphical
Task Display the string       Goodbye, World!       on a GUI object   (alert box, plain window, text area, etc.). Related task   Hello world/Text
#Clean
Clean
import StdEnv, StdIO   Start :: *World -> *World Start world = startIO NDI Void (snd o openDialog undef hello) [] world where hello = Dialog "" (TextControl "Goodbye, World!" []) [WindowClose (noLS closeProcess)]
http://rosettacode.org/wiki/GUI_enabling/disabling_of_controls
GUI enabling/disabling of controls
In addition to fundamental GUI component interaction, an application should dynamically enable and disable GUI components, to give some guidance to the user, and prohibit (inter)actions which are inappropriate in the current state of the application. Task Similar to the task GUI component interaction, write a progr...
#C.23
C#
using System; using System.ComponentModel; using System.Windows.Forms;   class RosettaInteractionForm : Form {   // Model used for DataBinding. // Notifies bound controls about Value changes. class NumberModel: INotifyPropertyChanged { // initialize event with empty delegate to avoid chec...
http://rosettacode.org/wiki/Happy_numbers
Happy numbers
From Wikipedia, the free encyclopedia: A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals   1   (where it will stay),   or it loops endlessly in a cycle which does not inclu...
#ALGOL-M
ALGOL-M
begin integer function mod(a,b); integer a,b; mod := a-(a/b)*b;   integer function sumdgtsq(n); integer n; sumdgtsq := if n = 0 then 0 else mod(n,10)*mod(n,10) + sumdgtsq(n/10);   integer function happy(n); integer n; begin integer i; integer array seen[0:200]; for i := 0 step 1 until 200 do seen[i]...
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#Swift
Swift
import Foundation   let startTime = NSDate() var signalReceived: sig_atomic_t = 0   signal(SIGINT) { signal in signalReceived = 1 }   for var i = 0;; { if signalReceived == 1 { break } usleep(500_000) if signalReceived == 1 { break } print(++i) }   let endTime = NSDate() print("Program has run for \(end...
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#Tcl
Tcl
package require Expect   proc sigint_handler {} { puts "elapsed time: [expr {[clock seconds] - $::start_time}] seconds" set ::looping false }   trap sigint_handler SIGINT   set start_time [clock seconds] set n 0 set looping true while {$looping} { puts [incr n] after 500 }
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#TXR
TXR
(set-sig-handler sig-int (lambda (signum async-p) (throwf 'error "caught signal ~s" signum)))   (let ((start-time (time))) (catch (each ((num (range 1))) (format t "~s\n" num) (usleep 500000)) (error (msg) (let ((end-time (time))) (...
http://rosettacode.org/wiki/Hash_join
Hash join
An inner join is an operation that combines two data tables into one table, based on matching column values. The simplest way of implementing this operation is the nested loop join algorithm, but a more scalable alternative is the hash join algorithm. Task[edit] Implement the "hash join" algorithm, and demonstrate tha...
#TXR
TXR
(defvar age-name '((27 Jonah) (18 Alan) (28 Glory) (18 Popeye) (28 Alan)))   (defvar nemesis-name '((Jonah Whales) (Jonah Spiders) (Alan Ghosts) (Alan Zombies) ...
http://rosettacode.org/wiki/Hash_join
Hash join
An inner join is an operation that combines two data tables into one table, based on matching column values. The simplest way of implementing this operation is the nested loop join algorithm, but a more scalable alternative is the hash join algorithm. Task[edit] Implement the "hash join" algorithm, and demonstrate tha...
#VBScript
VBScript
  Dim t_age(4,1) t_age(0,0) = 27 : t_age(0,1) = "Jonah" t_age(1,0) = 18 : t_age(1,1) = "Alan" t_age(2,0) = 28 : t_age(2,1) = "Glory" t_age(3,0) = 18 : t_age(3,1) = "Popeye" t_age(4,0) = 28 : t_age(4,1) = "Alan"   Dim t_nemesis(4,1) t_nemesis(0,0) = "Jonah" : t_nemesis(0,1) = "Whales" t_nemesis(1,0) = "Jonah" : t_nemesi...
http://rosettacode.org/wiki/Haversine_formula
Haversine formula
This page uses content from Wikipedia. The original article was at Haversine formula. 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) The haversine formula is an equation important in navigation, g...
#Elena
Elena
import extensions; import system'math;   Haversine(lat1,lon1,lat2,lon2) { var R := 6372.8r; var dLat := (lat2 - lat1).Radian; var dLon := (lon2 - lon1).Radian;   var dLat1 := lat1.Radian; var dLat2 := lat2.Radian;   var a := (dLat / 2).sin() * (dLat / 2).sin() + (dLon / 2).sin() * (dLon / 2).sin...
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#Mathematica_.2F_Wolfram_Language
Mathematica / Wolfram Language
NotebookWrite[EvaluationNotebook[], "Goodbye, World!"]
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#MATLAB_.2F_Octave
MATLAB / Octave
fprintf('Goodbye, World!');
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#min
min
"Goodbye, World!" print
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#ERRE
ERRE
  ! Hello World in ERRE language PROGRAM HELLO BEGIN PRINT("Hello world!") END PROGRAM  
http://rosettacode.org/wiki/Hash_from_two_arrays
Hash from two arrays
Task Using two Arrays of equal length, create a Hash object where the elements from one array (the keys) are linked to the elements of the other (the values) Related task   Associative arrays/Creation
#MATLAB_.2F_Octave
MATLAB / Octave
function s = StructFromArrays(allKeys, allVals) % allKeys must be cell array of strings of valid field-names % allVals can be cell array or array of numbers % Assumes arrays are same size and valid types s = struct; if iscell(allVals) for k = 1:length(allKeys) s.(allKeys{k}) = allVals{k}; ...
http://rosettacode.org/wiki/Hash_from_two_arrays
Hash from two arrays
Task Using two Arrays of equal length, create a Hash object where the elements from one array (the keys) are linked to the elements of the other (the values) Related task   Associative arrays/Creation
#MiniScript
MiniScript
keys = ["foo", "bar", "val"] values = ["little", "miss", "muffet"]   d = {} for i in range(keys.len-1) d[keys[i]] = values[i] end for   print d
http://rosettacode.org/wiki/Harshad_or_Niven_series
Harshad or Niven series
The Harshad or Niven numbers are positive integers ≥ 1 that are divisible by the sum of their digits. For example,   42   is a Harshad number as   42   is divisible by   (4 + 2)   without remainder. Assume that the series is defined as the numbers in increasing order. Task The task is to create a function/method/...
#FOCAL
FOCAL
01.10 S N=0 01.20 S P=0 01.30 D 3 01.40 I (19-P)1.7 01.50 T %4,N,! 01.60 S P=P+1 01.70 I (N-1001)1.3 01.80 T N,! 01.90 Q   02.10 S A=0 02.20 S B=N 02.30 S C=FITR(B/10) 02.40 S A=A+B-C*10 02.50 S B=C 02.60 I (-B)2.3   03.10 S N=N+1 03.20 D 2 03.30 I (FITR(N/A)*A-N)3.1
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#Tcl
Tcl
package require Tk proc maxSize {} { # Need a dummy window; max window can be changed by scripts set top .__defaultMaxSize__ if {![winfo exists $top]} { toplevel $top wm withdraw $top } # Default max size of window is value we want return [wm maxsize $top] }
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#Visual_Basic
Visual Basic
TYPE syswindowstru screenheight AS INTEGER screenwidth AS INTEGER maxheight AS INTEGER maxwidth AS INTEGER END TYPE   DIM syswindow AS syswindowstru   ' Determine the height and width of the screen syswindow.screenwidth = Screen.Width / Screen.TwipsPerPixelX syswindow.screenheight=Screen.Height / Screen.TwipsP...
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#Visual_Basic_.NET
Visual Basic .NET
Imports System.Drawing Imports System.Windows.Forms   Module Program Sub Main() Dim bounds As Rectangle = Screen.PrimaryScreen.Bounds Console.WriteLine($"Primary screen bounds: {bounds.Width}x{bounds.Height}")   Dim workingArea As Rectangle = Screen.PrimaryScreen.WorkingArea Console...
http://rosettacode.org/wiki/Hello_world/Graphical
Hello world/Graphical
Task Display the string       Goodbye, World!       on a GUI object   (alert box, plain window, text area, etc.). Related task   Hello world/Text
#Clojure
Clojure
(ns experimentation.core (:import (javax.swing JOptionPane JFrame JTextArea JButton) (java.awt FlowLayout)))   (JOptionPane/showMessageDialog nil "Goodbye, World!") (let [button (JButton. "Goodbye, World!") window (JFrame. "Goodbye, World!") text (JTextArea. "Goodbye, World!")] (doto window (.s...
http://rosettacode.org/wiki/GUI_enabling/disabling_of_controls
GUI enabling/disabling of controls
In addition to fundamental GUI component interaction, an application should dynamically enable and disable GUI components, to give some guidance to the user, and prohibit (inter)actions which are inappropriate in the current state of the application. Task Similar to the task GUI component interaction, write a progr...
#C.2B.2B
C++
file task.h
http://rosettacode.org/wiki/Guess_the_number/With_feedback_(player)
Guess the number/With feedback (player)
Task Write a player for the game that follows the following rules: The scorer will choose a number between set limits. The computer player will print a guess of the target number. The computer asks for a score of whether its guess is higher than, lower than, or equal to the target. The computer guesses, and the score...
#11l
11l
V (target_min, target_max) = (1, 10) V (mn, mx) = (target_min, target_max)   print( ‘Think of a number between #. and #. and wait for me to guess it. On every guess of mine you should state whether the guess was too high, too low, or equal to your number by typing h, l, or = ’.format(target_min, target_max))   V i = 0 ...
http://rosettacode.org/wiki/Happy_numbers
Happy numbers
From Wikipedia, the free encyclopedia: A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals   1   (where it will stay),   or it loops endlessly in a cycle which does not inclu...
#ALGOL_W
ALGOL W
begin  % find some happy numbers  %  % returns true if n is happy, false otherwise; n must be >= 0  % logical procedure isHappy( integer value n ) ; if n < 2 then true else begin  % seen is used to hold the values of the cycle of the  % ...
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#UNIX_Shell
UNIX Shell
c="1" # Trap signals for SIGQUIT (3), SIGABRT (6) and SIGTERM (15) trap "echo -n 'We ran for ';echo -n `expr $c /2`; echo " seconds"; exit" 3 6 15 while [ "$c" -ne 0 ]; do # infinite loop # wait 0.5 # We need a helper program for the half second interval c=`expr $c + 1` done
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#Visual_Basic_.NET
Visual Basic .NET
Module Module1 Dim startTime As Date   Sub Main() startTime = Date.Now ' Add event handler for Cntrl+C command AddHandler Console.CancelKeyPress, AddressOf Console_CancelKeyPress   Dim counter = 0 While True counter += 1 Console.WriteLine(counter) ...
http://rosettacode.org/wiki/Hash_join
Hash join
An inner join is an operation that combines two data tables into one table, based on matching column values. The simplest way of implementing this operation is the nested loop join algorithm, but a more scalable alternative is the hash join algorithm. Task[edit] Implement the "hash join" algorithm, and demonstrate tha...
#Visual_FoxPro
Visual FoxPro
  LOCAL i As Integer, n As Integer CLOSE DATABASES ALL *!* Create and populate the hash tables CREATE CURSOR people_ids(id I, used L DEFAULT .F.) INDEX ON id TAG id COLLATE "Machine" INDEX ON used TAG used BINARY COLLATE "Machine" SET ORDER TO 0 CREATE CURSOR nem_ids(id I, used L DEFAULT .F.) INDEX ON id TAG id COLLATE...
http://rosettacode.org/wiki/Hash_join
Hash join
An inner join is an operation that combines two data tables into one table, based on matching column values. The simplest way of implementing this operation is the nested loop join algorithm, but a more scalable alternative is the hash join algorithm. Task[edit] Implement the "hash join" algorithm, and demonstrate tha...
#Wren
Wren
import "/fmt" for Fmt   class A { construct new(age, name) { _age = age _name = name }   age { _age } name { _name } }   class B { construct new(character, nemesis) { _character = character _nemesis = nemesis }   character { _character } nemesis { _nem...
http://rosettacode.org/wiki/Haversine_formula
Haversine formula
This page uses content from Wikipedia. The original article was at Haversine formula. 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) The haversine formula is an equation important in navigation, g...
#Elixir
Elixir
defmodule Haversine do @v  :math.pi / 180 @r 6372.8 # km for the earth radius def distance({lat1, long1}, {lat2, long2}) do dlat = :math.sin((lat2 - lat1) * @v / 2) dlong = :math.sin((long2 - long1) * @v / 2) a = dlat * dlat + dlong * dlong * :math.cos(lat1 * @v) * :math.cos(lat2 * @v) ...
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#mIRC_Scripting_Language
mIRC Scripting Language
echo -ag Goodbye, World!
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#ML.2FI
ML/I
Goodbye, World!
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#Euler_Math_Toolbox
Euler Math Toolbox
"Hello world!"
http://rosettacode.org/wiki/Hash_from_two_arrays
Hash from two arrays
Task Using two Arrays of equal length, create a Hash object where the elements from one array (the keys) are linked to the elements of the other (the values) Related task   Associative arrays/Creation
#Neko
Neko
/** <doc><h2>Hash from two arrays, in Neko</h2></doc> **/   var sprintf = $loader.loadprim("std@sprintf", 2)   var array_keys = $array("one",2,"three",4,"five") var array_vals = $array("six",7,"eight",9,"zero") var elements = $asize(array_keys)   var table = $hnew(elements)   var step = elements while (step -= 1) >= 0...
http://rosettacode.org/wiki/Hash_from_two_arrays
Hash from two arrays
Task Using two Arrays of equal length, create a Hash object where the elements from one array (the keys) are linked to the elements of the other (the values) Related task   Associative arrays/Creation
#Nemerle
Nemerle
using System; using System.Console; using Nemerle.Collections; using Nemerle.Collections.NCollectionsExtensions;   module AssocArray { Main() : void { def list1 = ["apples", "oranges", "bananas", "kumquats"]; def list2 = [13, 34, 12]; def inventory = Hashtable(ZipLazy(list1, list2)); ...
http://rosettacode.org/wiki/Harshad_or_Niven_series
Harshad or Niven series
The Harshad or Niven numbers are positive integers ≥ 1 that are divisible by the sum of their digits. For example,   42   is a Harshad number as   42   is divisible by   (4 + 2)   without remainder. Assume that the series is defined as the numbers in increasing order. Task The task is to create a function/method/...
#Fortran
Fortran
  !-*- mode: compilation; default-directory: "/tmp/" -*- !Compilation started at Tue May 21 13:15:59 ! !a=./f && make $a && $a < unixdict.txt !gfortran -std=f2003 -Wall -ffree-form f.f03 -o f ! 1 2 3 4 5 6 7 8 9 10 12 18 20 21 24 27 30 36 40 42 1002 ! !Compilation finish...
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#Wren
Wren
import "input" for Keyboard import "dome" for Window, Process import "graphics" for Canvas, Color   class Game { static init() { Canvas.print("Maximize the window and press 'm'", 0, 0, Color.white) }   static update() { if (Keyboard.isKeyDown("m") ) { System.print("Maximum window...
http://rosettacode.org/wiki/GUI/Maximum_window_dimensions
GUI/Maximum window dimensions
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations an...
#XPL0
XPL0
int A; [A:= GetFB; Text(0, "Width = "); IntOut(0, A(0)); CrLf(0); Text(0, "Height = "); IntOut(0, A(1)); CrLf(0); ]
http://rosettacode.org/wiki/Hello_world/Graphical
Hello world/Graphical
Task Display the string       Goodbye, World!       on a GUI object   (alert box, plain window, text area, etc.). Related task   Hello world/Text
#COBOL
COBOL
CLASS-ID ProgramClass. METHOD-ID Main STATIC. PROCEDURE DIVISION. INVOKE TYPE Application::EnableVisualStyles() *> Optional INVOKE TYPE MessageBox::Show("Goodbye, World!") END METHOD. END CLASS.
http://rosettacode.org/wiki/GUI_enabling/disabling_of_controls
GUI enabling/disabling of controls
In addition to fundamental GUI component interaction, an application should dynamically enable and disable GUI components, to give some guidance to the user, and prohibit (inter)actions which are inappropriate in the current state of the application. Task Similar to the task GUI component interaction, write a progr...
#Delphi
Delphi
type TForm1 = class(TForm) MaskEditValue: TMaskEdit; // Set Editmask on: "99;0; " SpeedButtonIncrement: TSpeedButton; SpeedButtonDecrement: TSpeedButton; procedure MaskEditValueChange(Sender: TObject); procedure SpeedButtonDecrementClick(Sender: TObject); procedure SpeedButtonIncrementClick(Se...
http://rosettacode.org/wiki/Guess_the_number/With_feedback_(player)
Guess the number/With feedback (player)
Task Write a player for the game that follows the following rules: The scorer will choose a number between set limits. The computer player will print a guess of the target number. The computer asks for a score of whether its guess is higher than, lower than, or equal to the target. The computer guesses, and the score...
#Action.21
Action!
PROC Main() BYTE n,min=[1],max=[100] CHAR c   PrintF("Think a number in range %B-%B%E",min,max) DO n=(max+min) RSH 1 PrintF("My guess is %B%E",n) PrintF("Is it (E)qual, (L)ower or (H)igher?") c=GetD(7) Put(c) PutE() IF c='E THEN Print("I guessed!") EXIT ELSEIF c='L THEN ...
http://rosettacode.org/wiki/Guess_the_number/With_feedback_(player)
Guess the number/With feedback (player)
Task Write a player for the game that follows the following rules: The scorer will choose a number between set limits. The computer player will print a guess of the target number. The computer asks for a score of whether its guess is higher than, lower than, or equal to the target. The computer guesses, and the score...
#Ada
Ada
with Ada.Text_IO; procedure Guess_Number_Player is procedure Guess_Number (Lower_Limit : Integer; Upper_Limit : Integer) is type Feedback is (Lower, Higher, Correct); package Feedback_IO is new Ada.Text_IO.Enumeration_IO (Feedback); My_Guess : Integer := Lower_Limit + (Upper_Limit - Lower_Limit) / ...
http://rosettacode.org/wiki/Happy_numbers
Happy numbers
From Wikipedia, the free encyclopedia: A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals   1   (where it will stay),   or it loops endlessly in a cycle which does not inclu...
#APL
APL
∇ HappyNumbers arg;⎕IO;∆roof;∆first;bin;iroof [1] ⍝0: Happy number [2] ⍝1: http://rosettacode.org/wiki/Happy_numbers [3] ⎕IO←1 ⍝ Index origin [4] ∆roof ∆first←2↑arg,10 ⍝ [5] [6] bin←{ [7] ⍺←⍬ ⍝ Default left arg [8] ⍵=1:...
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#Visual_FoxPro
Visual FoxPro
  *!* In VFP, Ctrl+C is normally used to copy text to the clipboard. *!* Esc is used to stop execution. CLEAR SET ESCAPE ON ON ESCAPE DO StopLoop CLEAR DLLS DECLARE Sleep IN WIN32API INTEGER nMilliSeconds lLoop = .T. n = 0 ? "Press Esc to Cancel..." t1 = INT(SECONDS()) DO WHILE lLoop n = n + 1 ? n Sleep(500) ENDDO ...
http://rosettacode.org/wiki/Handle_a_signal
Handle a signal
Most operating systems provide interrupt facilities, sometimes called signals either generated by the user or as a result of program failure or reaching a limit like file space. Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are created so that the program behaves in a well-defi...
#Wren
Wren
import "scheduler" for Scheduler import "timer" for Timer import "io" for Stdin   var start = System.clock var stop = false   Scheduler.add { var n = 0 while (true) { System.print(n) if (stop) { var elapsed = System.clock - start + n * 0.5 System.print("Program has run fo...
http://rosettacode.org/wiki/Hash_join
Hash join
An inner join is an operation that combines two data tables into one table, based on matching column values. The simplest way of implementing this operation is the nested loop join algorithm, but a more scalable alternative is the hash join algorithm. Task[edit] Implement the "hash join" algorithm, and demonstrate tha...
#zkl
zkl
ageName:=T(27,"Jonah", 18,"Alan", 28,"Glory", 18,"Popeye", 28,"Alan"); nameNemesis:=T("Jonah","Whales", "Jonah","Spiders", "Alan","Ghosts", "Alan","Zombies", "Glory","Buffy");   fcn addAN(age,name,d){ // keys are names, values are ( (age,...),() ) if (r:=d.find(name)) d[name] = T(r[0].append(age),r[1]); e...
http://rosettacode.org/wiki/Haversine_formula
Haversine formula
This page uses content from Wikipedia. The original article was at Haversine formula. 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) The haversine formula is an equation important in navigation, g...
#Elm
Elm
haversine : ( Float, Float ) -> ( Float, Float ) -> Float haversine ( lat1, lon1 ) ( lat2, lon2 ) = let r = 6372.8   dLat = degrees (lat2 - lat1)   dLon = degrees (lon2 - lon1)   a = (sin (dLat / 2)) ^ 2 ...
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#Modula-2
Modula-2
MODULE HelloWorld; FROM Terminal IMPORT WriteString,ReadChar;   BEGIN WriteString("Goodbye, World!"); ReadChar END HelloWorld.
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#N.2Ft.2Froff
N/t/roff
  Goodbye, World!  
http://rosettacode.org/wiki/Hello_world/Newline_omission
Hello world/Newline omission
Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output. Task Display the string   Goodbye, World!   without a trailing newline. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Standard error   Hello world/Text
#Nanoquery
Nanoquery
print "Goodbye, world!"
http://rosettacode.org/wiki/Hello_world/Text
Hello world/Text
Hello world/Text is part of Short Circuit's Console Program Basics selection. Task Display the string Hello world! on a text console. Related tasks   Hello world/Graphical   Hello world/Line Printer   Hello world/Newbie   Hello world/Newline omission   Hello world/Standard error   Hello world/Web server
#Extended_BrainF.2A.2A.2A
Extended BrainF***
[.>]@Hello world!