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/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
| #NetRexx | NetRexx | /* NetRexx program ****************************************************
* 04.11.2012 Walter Pachl derived from REXX
**********************************************************************/
options replace format comments java crossref savelog symbols nobinary
values='triangle quadrilateral pentagon hexagon heptagon o... |
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
| #Nim | Nim | import tables, sequtils
let keys = @['a','b','c']
let values = @[1, 2, 3]
let table = toTable zip(keys, values) |
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/... | #FreeBASIC | FreeBASIC | ' FB 1.05.0 Win64
Function sumDigits(n As Integer) As Integer
If n < 0 Then Return 0
Dim sum As Integer
While n > 0
sum += n Mod 10
n \= 10
Wend
Return sum
End Function
Function isHarshad(n As Integer) As Boolean
Return n Mod sumDigits(n) = 0
End Function
Print "The first 20 Harshad or Niven n... |
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
| #Cobra | Cobra |
@args -pkg:gtk-sharp-2.0
use Gtk
class MainProgram
def main
Application.init
dialog = MessageDialog(nil,
DialogFlags.DestroyWithParent,
MessageType.Info,
ButtonsType.Ok,
"Goodbye, World!")
dialog.run
dialog.destroy
|
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... | #Fantom | Fantom | using fwt
using gfx
class Main
{
public static Void main ()
{
Window
{
textField := Text
{
text = "0"
}
incButton := Button
{
text = "increment"
onAction.add |Event e|
{
if (textField.text != "")
{
try
... |
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... | #ALGOL_68 | ALGOL 68 | BEGIN
INT lower := 1;
INT upper := 100;
print( ( "Think of a number between ", whole( lower, 0 ), " and ", whole( upper, 0 ), newline ) );
print( ( "Please enter Y if I guess correctly, L is it is lower, G if it is greater or Q if you've had enough", newline ) );
WHILE
INT mi... |
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... | #AppleScript | AppleScript | on run
set howManyHappyNumbers to 8
set happyNumberList to {}
set globalCounter to 1
repeat howManyHappyNumbers times
repeat while not isHappy(globalCounter)
set globalCounter to globalCounter + 1
end repeat
set end of happyNumberList to globalCounter
set gl... |
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... | #X86_Assembly | X86 Assembly |
%define sys_signal 48
%define SIGINT 2
%define sys_time 13
extern usleep
extern printf
section .text
global _start
_sig_handler:
mov ebx, end_time
mov eax, sys_time
int 0x80
mov eax, dword [start_time]
mov ebx, dword [end_time]
sub ebx, eax
mov ax, 100
div ebx
push ebx
push p_time
cal... |
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... | #Erlang | Erlang | % Implementer by Arjun Sunel
-module(haversine).
-export([main/0]).
main() ->
haversine(36.12, -86.67, 33.94, -118.40).
haversine(Lat1, Long1, Lat2, Long2) ->
V = math:pi()/180,
R = 6372.8, % In kilometers
Diff_Lat = (Lat2 - Lat1)*V ,
Diff_Long = (Long2 - Long1)*V,
NLat = Lat1*... |
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
| #Neko | Neko | /**
hellonnl.neko
Tectonics:
nekoc hellonnl.neko
neko hellonnl
-or-
nekoc hellonnl.neko
nekotools boot hellonnl.n
./hellonnl
*/
$print("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
| #Nemerle | Nemerle | using System.Console;
module Hello
{
// as with C#, Write() does not append a newline
Write("Goodbye, world!");
// equivalently
Write("Goodbye, ");
Write("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
| #NetRexx | NetRexx | /* NetRexx */
options replace format comments java crossref symbols binary
say '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
| #Ezhil | Ezhil | printfn "%s" "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
| #Oberon-2 | Oberon-2 |
MODULE HashFromArrays;
IMPORT
ADT:Dictionary,
Object:Boxed;
TYPE
Key= STRING;
Value= Boxed.LongInt;
PROCEDURE Do;
VAR
a: ARRAY 128 OF Key;
b: ARRAY 128 OF Value;
hash: Dictionary.Dictionary(Key,Value);
i: INTEGER;
BEGIN
hash := NEW(Dictionary.Dictionary(Key,Value));
a[0] := ... |
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/... | #Frink | Frink |
isHarshad[n] := n mod sum[integerDigits[n]] == 0
c = 0
i = 1
while c<20
{
if isHarshad[i]
{
c = c + 1
println[i]
}
i = i + 1
}
println[]
i = 1000
do
i = i + 1
while ! isHarshad[i]
println[i]
|
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
| #CoffeeScript | CoffeeScript | alert "Goodbye, World!" |
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... | #FreeBASIC | FreeBASIC |
#Include "windows.bi"
Dim As HWND Window_Main, Edit_Number, Button_Inc, Button_Dec
Dim As MSG msg
Dim As Integer n
Dim As String text
'Create a window with an input field and two buttons:
Window_Main = CreateWindow("#32770", "GUI Enabling/Disabling of Controls", WS_OVERLAPPEDWINDOW Or WS_VISIBLE, 100, 100, 250, 2... |
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... | #AppleScript | AppleScript | -- defining the range of the number to be guessed
property minLimit : 1
property maxLimit : 100
on run
-- ask the user to think of a number in the given range
display dialog "Please think of a number between " & minLimit & " and " & maxLimit
-- prepare a variable for the lowest guessed value
set lowGuess to m... |
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... | #Applesoft_BASIC | Applesoft BASIC | 0 C = 8: DIM S(16):B = 10: PRINT "THE FIRST "C" HAPPY NUMBERS": FOR R = C TO 0 STEP 0:N = H: GOSUB 1: PRINT MID$ (" " + STR$ (H),1 + (R = C),255 * I);:R = R - I:H = H + 1: NEXT R: END
1 S = 0: GOSUB 3:I = N = 1: IF NOT Q THEN RETURN
2 FOR Q = 1 TO 0 STEP 0:S(S) = N:S = S + 1: GOSUB 6:N = T: GOSUB 3: NEXT Q: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... | #zkl | zkl | var t=Time.Clock.time;
try{ n:=0; while(1){(n+=1).println(); Atomic.sleep(0.5)} }
catch{ println("ran for ",Time.Clock.time-t," seconds"); System.exit() } |
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... | #ERRE | ERRE | % Implemented by Claudio Larini
PROGRAM HAVERSINE_DEMO
!$DOUBLE
CONST DIAMETER=12745.6
FUNCTION DEG2RAD(X)
DEG2RAD=X*π/180
END FUNCTION
FUNCTION RAD2DEG(X)
RAD2DEG=X*180/π
END FUNCTION
PROCEDURE HAVERSINE_DIST(TH1,PH1,TH2,PH2->RES)
LOCAL DX,DY,DZ
PH1=DEG2RAD(PH1-PH2)
TH1=DEG2RAD(TH1)
... |
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
| #NewLISP | NewLISP | (print "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
| #Nim | Nim | stdout.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
| #NS-HUBASIC | NS-HUBASIC | 10 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
| #F.23 | F# | printfn "%s" "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
| #Objeck | Objeck |
use Structure;
bundle Default {
class HashOfTwo {
function : Main(args : System.String[]) ~ Nil {
keys := ["1", "2", "3"];
vals := ["a", "b", "c"];
hash := StringHash->New();
each(i : vals) {
hash->Insert(keys[i], vals[i]->As(Base));
};
}
}
}
|
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
| #Objective-C | Objective-C | NSArray *keys = @[@"a", @"b", @"c"];
NSArray *values = @[@1, @2, @3];
NSDictionary *dict = [NSDictionary dictionaryWithObjects:values forKeys:keys]; |
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.C5.8Drmul.C3.A6 | Fōrmulæ | Public Sub Main()
Dim siCount, siLoop, siTotal, siCounter As Short
Dim sNo, sTemp As String
Dim sHold, sNiven As New String[]
For siCount = 1 To 1500
sNo = Str(siCount)
For siLoop = 1 To Len(sNo)
sHold.Add(Mid(sNo, siLoop, 1))
Next
For Each sTemp In sHold
siTotal += Val(sTemp)
Next
If siCount Mod ... |
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
| #Commodore_BASIC | Commodore BASIC |
1 rem hello world on graphics screen
2 rem commodore 64 version
10 print chr$(147): print " press c to clear bitmap area,"
15 print " any other key to continue"
20 get k$:if k$="" then 20
25 if k$<>"c" then goto 40
30 poke 53280,0:print chr$(147):print " clearing bitmap area... please wait..."
35 base=8192:for i=... |
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
| #Common_Lisp | Common Lisp | (use-package :ltk)
(defun show-message (text)
"Show message in a label on a Tk window"
(with-ltk ()
(let* ((label (make-instance 'label :text text))
(button (make-instance 'button :text "Done"
:command (lambda ()
... |
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... | #Gambas | Gambas | hValueBox As ValueBox 'We need a ValueBox
hButton0 As Button 'We need a button
hButton1 As Button 'We need another button
Public Sub Form_Open()
With Me ... |
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... | #Arturo | Arturo | print {:
Think of a number between 1 and 10 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 =
:}
rmin: 1
rmax: 10
while ø [
guess: random rmin rmax
print ["My guess is:" guess]
inputOk: false
whi... |
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... | #Arturo | Arturo | ord0: to :integer `0`
happy?: function [x][
n: x
past: new []
while [n <> 1][
s: to :string n
n: 0
loop s 'c [
i: (to :integer c) - ord0
n: n + i * i
]
if contains? past n -> return false
'past ++ n
]
return true
]
loop 0..3... |
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... | #Euler_Math_Toolbox | Euler Math Toolbox | >load spherical
Spherical functions for Euler.
>TNA=[rad(36,7.2),-rad(86,40.2)];
>LAX=[rad(33,56.4),-rad(118,24)];
>esdist(TNA,LAX)->km
2886.48817482
>type esdist
function esdist (frompos: vector, topos: vector)
r1=rearth(frompos[1]);
r2=rearth(topos[1]);
xfrom=spoint(frompos)*r1;
xto=spoint(t... |
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... | #Excel | Excel | HAVERSINE
=LAMBDA(lla,
LAMBDA(llb,
LET(
REM, "Approximate radius of Earth in km.",
earthRadius, 6372.8,
sinHalfDeltaSquared, LAMBDA(x, SIN(x / 2) ^ 2)(
RADIANS(llb - lla)
),
2 * earthRadius * ASIN(
SQRT(
... |
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
| #Oberon-2 | Oberon-2 |
MODULE HelloWorld;
IMPORT Out;
BEGIN
Out.String("Goodbye, world!")
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
| #Objeck | Objeck |
bundle Default {
class SayGoodbye {
function : Main(args : String[]) ~ Nil {
"Goodbye, World!"->Print();
}
}
}
|
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
| #OCaml | OCaml | print_string "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
| #Factor | Factor | "Hello world!" print |
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
| #OCaml | OCaml | let keys = [ "foo"; "bar"; "baz" ]
and vals = [ 16384; 32768; 65536 ]
and hash = Hashtbl.create 0;;
List.iter2 (Hashtbl.add hash) keys vals;; |
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
| #ooRexx | ooRexx | array1 = .array~of("Rick", "Mike", "David")
array2 = .array~of("555-9862", "555-5309", "555-6666")
-- if the index items are constrained to string objects, this can
-- be a directory too.
hash = .table~new
loop i = 1 to array1~size
hash[array1[i]] = array2[i]
end
Say 'Enter a name'
Parse Pull name
Say name '->'... |
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/... | #Gambas | Gambas | Public Sub Main()
Dim siCount, siLoop, siTotal, siCounter As Short
Dim sNo, sTemp As String
Dim sHold, sNiven As New String[]
For siCount = 1 To 1500
sNo = Str(siCount)
For siLoop = 1 To Len(sNo)
sHold.Add(Mid(sNo, siLoop, 1))
Next
For Each sTemp In sHold
siTotal += Val(sTemp)
Next
If siCount Mod ... |
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
| #Creative_Basic | Creative Basic |
DEF Win:WINDOW
DEF Close:CHAR
DEF ScreenSizeX,ScreenSizeY:INT
GETSCREENSIZE(ScreenSizeX,ScreenSizeY)
WINDOW Win,0,0,ScreenSizeX,ScreenSizeY,0,0,"Goodbye program",MainHandler
PRINT Win,"Goodbye, World!"
'Prints in the upper left corner of the window (position 0,0).
WAITUNTIL Close=1
CLOSEWINDOW Win
END
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... | #Go | Go | package main
import (
"github.com/gotk3/gotk3/gtk"
"log"
"math/rand"
"strconv"
"time"
)
func validateInput(window *gtk.Window, str string) (int64, bool) {
i, err := strconv.ParseInt(str, 10, 64)
if err != nil {
dialog := gtk.MessageDialogNew(
window,
gtk.D... |
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... | #AsciiDots | AsciiDots |
/.
*$"Think of a number from 1 to 127"
*$"Enter H if my guess is too high" /#67\
*-$"Enter L if my guess is too low" *--{=}:$""$"I WIN"&
\-$"Enter C if my guess is correct"\| /------~*{-}\
/23@-------------------------------/|/#72\ | !| @ |
\#64>*$_"Is it "$_#$_"? (H/L/C) "#a?**--{=}+------/\-/ |
/---/| ... |
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... | #AutoHotkey | AutoHotkey | MaxGuesses = 50
GetParams(LowerBound,UpperBound)
If Not GuessNum(LowerBound,UpperBound,MaxGuesses)
MsgBox, 16, Error, Could not guess number within %MaxGuesses% guesses.
GetParams(ByRef LowerBound,ByRef UpperBound)
{
WinWait, Number Guessing ahk_class #32770
Sleep, 100
WinGet, InputID, ID
ControlGetText, Temp1... |
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... | #AutoHotkey | AutoHotkey | Loop {
If isHappy(A_Index) {
out .= (out="" ? "" : ",") . A_Index
i ++
If (i = 8) {
MsgBox, The first 8 happy numbers are: %out%
ExitApp
}
}
}
isHappy(num, list="") {
list .= (list="" ? "" : ",") . num
Loop, Parse, num
sum += A_LoopField ** 2
If (sum = 1)
Return true
El... |
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... | #F.23 | F# | open System
[<Measure>] type deg
[<Measure>] type rad
[<Measure>] type km
let haversine (θ: float<rad>) = 0.5 * (1.0 - Math.Cos(θ/1.0<rad>))
let radPerDeg = (Math.PI / 180.0) * 1.0<rad/deg>
type pos(latitude: float<deg>, longitude: float<deg>) =
member this.φ = latitude * radPerDeg
member this.ψ = long... |
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
| #Oforth | Oforth | "Goodbye, World!" print |
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
| #Ol | Ol |
(display "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
| #OOC | OOC | main: func {
"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
| #Falcon | Falcon | printl("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
| #Oz | Oz | declare
fun {ZipRecord Keys Values}
{List.toRecord unit {List.zip Keys Values MakePair}}
end
fun {MakePair A B}
A#B
end
in
{Show {ZipRecord [a b c] [1 2 3]}} |
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
| #PARI.2FGP | PARI/GP | hash(key, value)=Map(matrix(#key,2,x,y,if(y==1,key[x],value[x]))); |
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/... | #Go | Go | package main
import "fmt"
type is func() int
func newSum() is {
var ms is
ms = func() int {
ms = newSum()
return ms()
}
var msd, d int
return func() int {
if d < 9 {
d++
} else {
d = 0
msd = ms()
}
return msd +... |
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
| #D | D | import gtk.MainWindow, gtk.Label, gtk.Main;
class GoodbyeWorld : MainWindow {
this() {
super("GtkD");
add(new Label("Goodbye World"));
showAll();
}
}
void main(string[] args) {
Main.init(args);
new GoodbyeWorld();
Main.run();
} |
http://rosettacode.org/wiki/GUI_component_interaction | GUI component interaction |
Almost every application needs to communicate with the user in some way.
Therefore, a substantial part of the code deals with the interaction
of program logic with GUI components.
Typically, the following is needed:
put values into input fields under program control
read and check input from the user
pop up dial... | #1C | 1C |
&НаСервере
Процедура ДобавитьЭлементы()
КЧ = Новый КвалификаторыЧисла(12,2);
Массив = Новый Массив;
Массив.Добавить(Тип("Число"));
ОписаниеТиповЧ = Новый ОписаниеТипов(Массив, , ,КЧ);
НовыйРеквизит = Новый РеквизитФормы("ВводимоеЧисло", Новый ОписаниеТипов(Массив, , ,КЧ));;
МассивР = Новый Массив;
Масс... |
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... | #Icon_and_Unicon | Icon and Unicon |
import gui
$include "guih.icn"
class MessageDialog : Dialog (message)
method component_setup ()
label := Label ("label="||message, "pos=20,20")
add (label)
button := TextButton("label=OK", "pos=100,60")
button.connect (self, "dispose", ACTION_EVENT)
add (button)
connect (self, "dispose",... |
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... | #Batch_File | Batch File |
@echo off
:: Player is prompted to give a number between %min% and %max%. If the input is out of those limits they are prompted to choose again
:choose
set min=0
set max=100
set /p "number=Choose a number [%min%-%max%]: "
if %number% gtr %max% goto choose
if %number% lss %min% goto choose
set attempts=0
:: Loops ... |
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... | #AutoIt | AutoIt |
$c = 0
$k = 0
While $c < 8
$k += 1
$n = $k
While $n <> 1
$s = StringSplit($n, "")
$t = 0
For $i = 1 To $s[0]
$t += $s[$i] ^ 2
Next
$n = $t
Switch $n
Case 4,16,37,58,89,145,42,20
ExitLoop
EndSwitch
WEnd
If $n = 1 Then
ConsoleWrite($k & " is Happy" & @CRLF)
$c += 1
EndIf
WEnd
|
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... | #Factor | Factor | USING: arrays kernel math math.constants math.functions math.vectors sequences ;
: haversin ( x -- y ) cos 1 swap - 2 / ;
: haversininv ( y -- x ) 2 * 1 swap - acos ;
: haversineDist ( as bs -- d )
[ [ 180 / pi * ] map ] bi@
[ [ swap - haversin ] 2map ]
[ [ first cos ] bi@ * 1 swap 2array ]
2bi
v.
haversininv R... |
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
| #Oxygene | Oxygene |
namespace HelloWorld;
interface
type
HelloWorld = class
public
class method Main;
end;
implementation
class method HelloWorld.Main;
begin
Console.Write('Farewell, ');
Console.Write('cruel ');
Console.WriteLine('world!');
end;
end.
|
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
| #Panoramic | Panoramic |
rem insert a trailing semicolon.
print "Goodbye, World!";
print " Nice having known you." |
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
| #PARI.2FGP | PARI/GP | print1("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
| #FALSE | FALSE | "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
| #Pascal | Pascal | program HashFromTwoArrays (Output);
uses
contnrs;
var
keys: array[1..3] of string = ('a', 'b', 'c');
values: array[1..3] of integer = ( 1, 2, 3 );
hash: TFPDataHashTable;
i: integer;
begin
hash := TFPDataHashTable.Create;
for i := low(keys) to high(keys) do
hash.add(keys[i], @value... |
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/... | #Groovy | Groovy |
class HarshadNiven{ public static boolean find(int x)
{
int sum = 0,temp,var;
var = x;
while(x>0)
{
temp = x%10;
sum = sum + temp;
x = x/10;
}
if(var%sum==0) temp = 1;
else temp = 0;
return temp;
}
public static void main(String[] args)
... |
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
| #Dart | Dart | import 'package:flutter/material.dart';
main() => runApp( MaterialApp( home: Text( "Goodbye, World!" ) ) );
|
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
| #Delphi | Delphi | program HelloWorldGraphical;
uses
Dialogs;
begin
ShowMessage('Goodbye, World!');
end. |
http://rosettacode.org/wiki/GUI_component_interaction | GUI component interaction |
Almost every application needs to communicate with the user in some way.
Therefore, a substantial part of the code deals with the interaction
of program logic with GUI components.
Typically, the following is needed:
put values into input fields under program control
read and check input from the user
pop up dial... | #Ada | Ada | with Ada.Numerics.Discrete_Random;
with Ada.Strings.Fixed;
with Gtk.Main;
with Gtk.Handlers;
with Gtk.Button;
with Gtk.Window;
with Gtk.GEntry;
with Gtk.Editable;
with Gtk.Box;
with Gtk.Widget;
with Glib.Values;
with Gtkada.Dialogs;
procedure Interaction is
The_Value : Natural := 0;
package Natural_Random i... |
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... | #J | J | task_run=: wd bind (noun define)
pc task nosize;
cc decrement button;cn "Decrement";
cc increment button;cn "Increment";
cc Value edit center;set Value text 0;
set decrement enable 0;
pas 6 6;pcenter;
pshow;
)
task_cancel=: task_close=: wd bind 'pclose'
task_Value_button=: update=: verb define
wd 's... |
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... | #BASIC | BASIC | 10 DEFINT A-Z
20 INPUT "Lower limit? ",L
30 INPUT "Upper limit? ",H
40 IF L>H THEN PRINT "Invalid input": END
50 PRINT "My guess is ";(H-L)\2+L
55 T=T+1
60 INPUT "Too low (L), too high (H), or correct (C)? ",R$
70 ON INSTR("LlHhCc",R$) GOTO 90,90,100,100,110,110
80 PRINT "Invalid input": GOTO 50
90 L=(H-L)\2+L: GOTO 40... |
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... | #BBC_BASIC | BBC BASIC | min% = 1
max% = 100
PRINT "Think of a number between "; min% " and " ;max%
PRINT "I will try to guess your number."
REPEAT
guess% = (min% + max%) DIV 2
PRINT "My guess is " ; guess%
INPUT "Is it higher than, lower than or equal to your number", answer$
CASE ... |
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... | #AWK | AWK | function is_happy(n)
{
if ( n in happy ) return 1;
if ( n in unhappy ) return 0;
cycle[""] = 0
while( (n!=1) && !(n in cycle) ) {
cycle[n] = n
new_n = 0
while(n>0) {
d = n % 10
new_n += d*d
n = int(n/10)
}
n = new_n
}
if ( n == 1 ) {
for (i_ in cycle) {
happy[... |
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... | #FBSL | FBSL | #APPTYPE CONSOLE
PRINT "Distance = ", Haversine(36.12, -86.67, 33.94, -118.4), " km"
PAUSE
FUNCTION Haversine(DegLat1 AS DOUBLE, DegLon1 AS DOUBLE, DegLat2 AS DOUBLE, DegLon2 AS DOUBLE) AS DOUBLE
CONST radius = 6372.8
DIM dLat AS DOUBLE = D2R(DegLat2 - DegLat1)
DIM dLon AS DOUBLE = D2R(DegLon2 - DegLon1... |
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
| #Pascal | Pascal | program NewLineOmission(output);
begin
write('Goodbye, World!');
end. |
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
| #PASM | PASM | print "Goodbye World!" # Newlines do not occur unless we embed them
end |
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
| #Perl | Perl | print "Goodbye, World!"; # A newline does not occur automatically |
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
| #Phix | Phix | puts(1,"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
| #Fantom | Fantom |
class HelloText
{
public static Void main ()
{
echo ("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
| #Perl | Perl | my @keys = qw(a b c);
my @vals = (1, 2, 3);
my %hash;
@hash{@keys} = @vals; |
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
| #Phix | Phix | with javascript_semantics
function make_hash(sequence keyarray, sequence valuearray)
integer dict = new_dict()
for i=1 to length(keyarray) do
setd(keyarray[i],valuearray[i],dict)
-- setd(keyarray[i],i,dict)
end for
return dict
end function
constant keyarray = {1,"two",PI}
constant value... |
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/... | #Haskell | Haskell | import Data.Char (digitToInt)
harshads :: [Int]
harshads =
let digsum = sum . map digitToInt . show
in filter ((0 ==) . (mod <*> digsum)) [1 ..]
main :: IO ()
main = mapM_ print [take 20 harshads, [(head . filter (> 1000)) harshads]] |
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
| #Diego | Diego | display_me()_msg(Goodbye, World!); |
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
| #Dylan | Dylan | notify-user("Goodbye, World!", frame: make(<frame>)); |
http://rosettacode.org/wiki/GUI_component_interaction | GUI component interaction |
Almost every application needs to communicate with the user in some way.
Therefore, a substantial part of the code deals with the interaction
of program logic with GUI components.
Typically, the following is needed:
put values into input fields under program control
read and check input from the user
pop up dial... | #AutoHotkey | AutoHotkey | GUI, add, Edit,Number w50 vUserInput gMakeSure, 0 ; Number Specifies Numbers-only, but other characters can still be pasted in,
; Making our own check necessary. (MakeSure)
GUI, add, Button, gIncrement, Increment ; Instead of an increment button, the UpDown control could be used, but this was not sp... |
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... | #Java | Java | import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
... |
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... | #BCPL | BCPL | get "libhdr"
let reads(s) = valof
$( s%0 := 0
$( let c = rdch()
if c = endstreamch resultis false
if c = '*N' resultis true
s%0 := s%0 + 1
s%(s%0) := c
$) repeat
$)
let choose(chs) = valof
$( let ans = vec 80
writef("[%S]? ",chs)
unless reads(ans) finish
unles... |
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... | #C | C | #include <stdio.h>
int main(){
int bounds[ 2 ] = {1, 100};
char input[ 2 ] = " ";
/* second char is for the newline from hitting [return] */
int choice = (bounds[ 0 ] + bounds[ 1 ]) / 2;
/* using a binary search */
printf( "Choose a number between %d and %d.\n", bounds[ 0 ], bounds[ 1 ] );
do{
... |
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... | #BASIC256 | BASIC256 | n = 1 : cnt = 0
print "The first 8 isHappy numbers are:"
print
while cnt < 8
if isHappy(n) = 1 then
cnt += 1
print cnt; " => "; n
end if
n += 1
end while
function isHappy(num)
isHappy = 0
cont = 0
while cont < 50 and isHappy <> 1
num$ = string(num)
cont += 1
... |
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... | #FOCAL | FOCAL | 1.01 S BA = 36.12; S LA = -86.67
1.02 S BB = 33.94; S LB = -118.4
1.03 S DR = 3.1415926536 / 180; S D = 2 * 6372.8
1.04 S TA = (LB - LA) * DR
1.05 S TB = DR * BA
1.06 S TC = DR * BB
1.07 S DZ = FSIN(TB) - FSIN(TC)
1.08 S DX = FCOS(TA) * FCOS(TB) - FCOS(TC)
1.09 S DY = FSIN(TA) * FCOS(TB)
1.10 S AS = DX * DX + DY * DY +... |
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
| #PHL | PHL | module helloworld_noln;
extern printf;
@Integer main [
printf("Goodbye, World!");
return 0;
] |
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
| #PHP | PHP | echo "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
| #Picat | Picat | 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
| #Fennel | Fennel | (print "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
| #Phixmonti | Phixmonti | include ..\Utilitys.pmt
def getd /# array key -- array data #/
swap 1 get rot find nip
dup if
swap 2 get rot get nip
else
drop "Unfound"
endif
enddef
( ( 1 "two" PI ) ( "one" 2 PI ) ) /# keys / data #/
1 getd print nl
"two" getd print nl
PI getd tostr print nl
3 getd print |
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
| #PHP | PHP | $keys = array('a', 'b', 'c');
$values = array(1, 2, 3);
$hash = array_combine($keys, $values); |
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/... | #Icon_and_Unicon | Icon and Unicon | procedure main(A)
limit := integer(A[1]) | 20
every writes(niven(seq())\limit," ")
writes("... ")
write(niven(seq(1001))\1)
end
procedure niven(n)
n ? {s := 0; while s +:= move(1)}
if (n%s) = 0 then return n
end |
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
| #E | E | def <widget> := <swt:widgets.*>
def SWT := <swt:makeSWT>
def frame := <widget:makeShell>(currentDisplay)
frame.setText("Rosetta Code")
frame.setBounds(30, 30, 230, 60)
frame.addDisposeListener(def _ { to widgetDisposed(event) {
interp.continueAtTop()
}})
def label := <widget:makeLabel>(frame, SWT.getLEF... |
http://rosettacode.org/wiki/GUI_component_interaction | GUI component interaction |
Almost every application needs to communicate with the user in some way.
Therefore, a substantial part of the code deals with the interaction
of program logic with GUI components.
Typically, the following is needed:
put values into input fields under program control
read and check input from the user
pop up dial... | #BaCon | BaCon | OPTION GUI TRUE
PRAGMA GUI gtk3
DECLARE (*show)() = gtk_widget_show_all TYPE void
DECLARE (*hide)() = gtk_widget_hide TYPE void
gui = GUIDEFINE(" \
{ type=WINDOW name=window callback=delete-event title=\"Rosetta Code\" width-request=200 } \
{ type=BOX name=box parent=window orientation=GTK_ORIENTATION_VERTI... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.