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/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... | #BBC_BASIC | BBC BASIC | INSTALL @lib$+"WINLIB2"
INSTALL @lib$+"WINLIB5"
IDYES = 6
ES_NUMBER = 8192
MB_YESNO = 4
form% = FN_newdialog("Rosetta Code", 100, 100, 100, 52, 8, 1000)
PROC_static(form%, "Value:", 100, 10, 10, 24, 14, 0)
PROC_editbox(form%, "0", 101, 40, 8, 52, 14, ES_NUMBER)
... |
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... | #Julia | Julia |
using Tk
w = Toplevel("GUI enabling/disabling")
fr = Frame(w)
pack(fr, {:expand=>true, :fill => "both"})
value = Entry(fr)
increment = Button(fr, "+")
decrement = Button(fr, "-")
formlayout(value, "Value:")
formlayout(increment, " ")
formlayout(decrement, " ")
## value stores a string
set_value(value, "0") ## T... |
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... | #Kotlin | Kotlin | // version 1.2.21
import javafx.application.Application
import javafx.beans.property.SimpleLongProperty
import javafx.scene.Scene
import javafx.scene.control.Button
import javafx.scene.control.TextField
import javafx.scene.layout.HBox
import javafx.scene.layout.VBox
import javafx.stage.Stage
import javafx.util.conver... |
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.23 | C# | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading; //Remember to add this if you want the game to pause in RealisticGuess.Start()
namespace ConsoleApplication1
{
class RealisticGuess //Simulates a guessing game between two people. Guessing efficiency is n... |
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... | #Batch_File | Batch File | @echo off
setlocal enableDelayedExpansion
::Define a list with 10 terms as a convenience for defining a loop
set "L10=0 1 2 3 4 5 6 7 8 9"
shift /1 & goto %1
exit /b
:list min count
:: This routine prints all happy numbers > min (arg1)
:: until it finds count (arg2) happy numbers.
set /a "n=%~1, cnt=%~2"
call :list... |
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... | #Forth | Forth | : s>f s>d d>f ;
: deg>rad 174532925199433e-16 f* ;
: difference f- deg>rad 2 s>f f/ fsin fdup f* ;
: haversine ( lat1 lon1 lat2 lon2 -- haversine)
frot difference ( lat1 lat2 dLon^2)
frot frot fover fover ( dLon^2 lat1 lat2 lat1 lat2)
fswap differen... |
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
| #PicoLisp | PicoLisp | (prin "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
| #Pict | Pict | (pr "Hello 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
| #Pike | Pike | 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
| #Pixilang | Pixilang | fputs("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
| #ferite | ferite | uses "console";
Console.println( "Goodby, 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
| #Picat | Picat | go =>
A = [a,b,c,d,e],
B = [1,2,3,4,5],
Map = new_map([K=V : {K,V} in zip(A,B)]),
println(Map). |
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
| #PicoLisp | PicoLisp | (let (Keys '(one two three) Values (1 2 3))
(mapc println
(mapcar cons 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/... | #IS-BASIC | IS-BASIC | 100 PROGRAM "Harshad.bas"
110 LET I=1:LET CNT=0
120 PRINT "First 20 Harshad numbers are:"
130 DO
140 IF HARSHAD(I) THEN PRINT I;:LET CNT=CNT+1
150 LET I=I+1
160 LOOP UNTIL CNT=20
170 PRINT :PRINT :PRINT "First Harshad number larger than 1000 is";:LET I=1001
180 DO
190 IF HARSHAD(I) THEN PRINT I:EXIT DO
200 LET ... |
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
| #EasyLang | EasyLang | move 10 20
text "Goodbye, World!" |
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... | #C | C | file main.c |
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... | #C.2B.2B | C++ | file interaction.h |
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... | #Liberty_BASIC | Liberty BASIC | nomainwin
textbox #demo.val, 20, 50, 90, 24
button #demo.dec, "Decrement", [btnDecrement], UL, 20, 90, 90, 24
button #demo.inc, "Increment", [btnIncrement], UL, 20, 120, 90, 24
statictext #demo.txt, "Positive or negative whole numbers only.", 20, 170, 240, 24
open "Rosetta Task: GUI enabling/disabli... |
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.2B.2B | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
struct GuessNumberIterator : std::iterator<std::random_access_iterator_tag, int> {
int i;
GuessNumberIterator() { }
GuessNumberIterator(int _i) : i(_i) { }
GuessNumberIterator& operator++() { ++i; return *this; }
GuessNumberItera... |
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... | #BBC_BASIC | BBC BASIC | number% = 0
total% = 0
REPEAT
number% += 1
IF FNhappy(number%) THEN
PRINT number% " is a happy number"
total% += 1
ENDIF
UNTIL total% = 8
END
DEF FNhappy(num%)
LOCAL digit&()
DIM digit&(10)
REPEAT
digit&() = 0
... |
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... | #Fortran | Fortran |
program example
implicit none
real :: d
d = haversine(36.12,-86.67,33.94,-118.40) ! BNA to LAX
print '(A,F9.4,A)', 'distance: ',d,' km' ! distance: 2887.2600 km
contains
function to_radian(degree) result(rad)
! degrees to radians
real,intent(in) :: degree
real, parameter :: d... |
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
| #PL.2FI | PL/I |
put ('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
| #Plain_English | Plain English | To run:
Start up.
Write "Goodbye, world!" on the console without advancing.
Wait for the escape key.
Shut down. |
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
| #PowerShell | PowerShell | Write-Host -NoNewLine "Goodbye, "
Write-Host -NoNewLine "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
| #Processing | Processing |
print("Goodbye, World!"); /* No automatic newline */
|
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
| #Fermat | Fermat | !!'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
| #Pike | Pike |
array indices = ({ "a", "b", 42 });
array values = ({ Image.Color(0,0,0), "hello", "world" });
mapping m = mkmapping( indices, values );
write("%O\n", m);
|
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
| #Pop11 | Pop11 | vars keys = { 1 a b c};
vars vals = { 2 3 valb valc};
vars i;
;;; Create hash table
vars ht = newmapping([], 500, 0, true);
;;; Loop over input arrays (vectors)
for i from 1 to length(keys) do
vals(i) -> ht(keys(i));
endfor; |
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/... | #J | J | Until =: 2 : 'u^:(-.@:v)^:_'
isHarshad =: 0 = ] |~ [: +/ #.inv NB. BASE isHarshad N
assert 1 0 -: 10 isHarshad&> 42 38
nextHarshad =: (>: Until (10&isHarshad))@:>:
assert 45 -: nextHarshad 42
assert 3 4 5 -: nextHarshad&> 2 3 4
assert 1 2 3 4 5 6 7 8 9 10 12 18 20 21 24 27 30 36 40 42 -: (, nextHarshad@:{:)Until (20 =... |
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
| #eC | eC | import "ecere"
MessageBox goodBye { contents = "Goodbye, World!" }; |
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... | #C_sharp | C_sharp | 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
{
Random rnd = new Random();
// initialize ev... |
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... | #LiveCode | LiveCode | command enableButtons v
switch
case v <= 0
put 0 into fld "Field1"
set the enabled of btn "Button1" to true
set the enabled of btn "Button2" to false
break
case v >= 10
put 10 into fld "Field1"
set the enabled of btn... |
http://rosettacode.org/wiki/Guess_the_number/With_feedback | Guess the number/With feedback | Task
Write a game (computer program) that follows the following rules:
The computer chooses a number between given set limits.
The player is asked for repeated guesses until the the target number is guessed correctly
At each guess, the computer responds with whether the guess is:
higher than the target,
equal to... | #11l | 11l | V (target_min, target_max) = (1, 100)
print("Guess my target number that is between #. and #. (inclusive).\n".format(target_min, target_max))
V target = random:(target_min..target_max)
V (answer, i) = (target_min - 1, 0)
L answer != target
i++
V txt = input(‘Your guess(#.): ’.format(i))
X.try
answer = ... |
http://rosettacode.org/wiki/Greyscale_bars/Display | Greyscale bars/Display | The task is to display a series of vertical greyscale bars (contrast bars) with a sufficient number of bars to span the entire width of the display.
For the top quarter of the display, the left hand bar should be black, and we then incrementally step through six shades of grey until we have a white bar on the right ha... | #ActionScript | ActionScript | package
{
import flash.display.Sprite;
[SWF(width="640", height="480")]
public class GreyscaleBars extends Sprite
{
public function GreyscaleBars()
{
_drawRow(8, 0);
_drawRow(16, stage.stageHeight/4, true);
_drawRow(32, stage.stageHeight/2);
_drawRow(64, stage.stageHeight/4 * 3, true);
}
p... |
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... | #Ceylon | Ceylon | shared void run() {
while(true) {
variable value low = 1;
variable value high = 10;
variable value attempts = 1;
print("Please choose a number between ``low`` and ``high``.
Press enter when ready.");
process.readLine();
while(true) {
if(low ... |
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... | #Clojure | Clojure | (require '[clojure.string :as str])
(defn guess-game [low high]
(printf "Think of a number between %s and %s.\n (use (h)igh (l)ow (c)orrect)\n" low high)
(loop [guess (/ (inc (- high low)) 2)
[step & more] (next (iterate #(/ % 2) guess))]
(printf "I guess %s\n=> " (Math/round (float guess)))
(flu... |
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... | #BCPL | BCPL | get "libhdr"
let sumdigitsq(n) =
n=0 -> 0, (n rem 10)*(n rem 10)+sumdigitsq(n/10)
let happy(n) = valof
$( let seen = vec 255
for i = 0 to 255 do i!seen := false
$( n!seen := true
n := sumdigitsq(n)
$) repeatuntil n!seen
resultis 1!seen
$)
let start() be
$( let n, i = 0, 0
while... |
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... | #Free_Pascal | Free Pascal | program HaversineDemo;
uses
Math;
function HaversineDistance(const lat1, lon1, lat2, lon2:double):double;inline;
const
rads = pi / 180;
dia = 2 * 6372.8;
begin
HaversineDistance := dia * arcsin(sqrt(sqr(cos(rads * (lon1 - lon2)) * cos(rads * lat1)
- cos(rads * lat2)) + sqr(sin(rads *... |
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
| #PureBasic | PureBasic | OpenConsole()
Print("Goodbye, World!")
Input() ;wait for enter key to be pressed |
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
| #Python | Python | import sys
sys.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
| #Quackery | Quackery | say "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
| #R | R | cat("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
| #Fexl | Fexl | say "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
| #PostScript | PostScript |
% push our arrays
[/a /b /c /d /e] [1 2 3 4 5]
% create a dict with it
{aload pop} dip let currentdict end
% show that we have created the hash
{= =} forall
|
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
| #PowerShell | PowerShell | function create_hash ([array] $keys, [array] $values) {
$h = @{}
if ($keys.Length -ne $values.Length) {
Write-Error -Message "Array lengths do not match" `
-Category InvalidData `
-TargetObject $values
} else {
for ($i = 0; $i -lt $keys.Length; $i++) {... |
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/... | #Java | Java | public class Harshad{
private static long sumDigits(long n){
long sum = 0;
for(char digit:Long.toString(n).toCharArray()){
sum += Character.digit(digit, 10);
}
return sum;
}
public static void main(String[] args){
for(int count = 0, i = 1; count < 20;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
| #EchoLisp | EchoLisp |
(alert "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
| #EGL | EGL |
import org.eclipse.edt.rui.widgets.*;
import dojo.widgets.*;
handler HelloWorld type RUIhandler{initialUI =[ui]}
ui Box {columns=1, children=[nameField, helloLabel, goButton]};
nameField DojoTextField {placeHolder = "What's your name?", text = "World"};
helloLabel TextLabel {};
goButton DojoButt... |
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... | #Common_Lisp | Common Lisp |
;; Using the LTK library...
(defun gui-test ()
"the main window for the input test"
(ltk:with-ltk ()
(ltk:wm-title ltk:*tk* "GUI Test")
(ltk:bind ltk:*tk* "<Alt-q>" (lambda (evt)
(declare (ignore evt))
(setf ltk:*exit-mainloop* t)))
(let* (;; Initializing random generator
(*random-... |
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... | #M2000_Interpreter | M2000 Interpreter |
\\ this is global, but call as local in events, which means with local visibility for identifiers
\\ so thispos and this$ has to exist in caller 's context
Function Global Local1(new Feed$) {
\\ this function can be used from other Integer
\\ this$ and thispos, exist just before the call of... |
http://rosettacode.org/wiki/Guess_the_number/With_feedback | Guess the number/With feedback | Task
Write a game (computer program) that follows the following rules:
The computer chooses a number between given set limits.
The player is asked for repeated guesses until the the target number is guessed correctly
At each guess, the computer responds with whether the guess is:
higher than the target,
equal to... | #Action.21 | Action! | PROC Main()
BYTE x,n,min=[1],max=[100]
PrintF("Try to guess a number %B-%B: ",min,max)
x=Rand(max-min+1)+min
DO
n=InputB()
IF n<min OR n>max THEN
Print("The input is incorrect. Try again: ")
ELSEIF n<x THEN
Print("My number is higher. Try again: ")
ELSEIF n>x THEN
Print("My n... |
http://rosettacode.org/wiki/Greyscale_bars/Display | Greyscale bars/Display | The task is to display a series of vertical greyscale bars (contrast bars) with a sufficient number of bars to span the entire width of the display.
For the top quarter of the display, the left hand bar should be black, and we then incrementally step through six shades of grey until we have a white bar on the right ha... | #Ada | Ada | with Gtk.Window; use Gtk.Window;
with Gtk.Enums;
with Gtk.Handlers;
with Gtk.Main;
with Gdk;
with Gdk.Event;
with Glib; use Glib;
with Cairo; use Cairo;
with Gdk.Cairo;
pragma Elaborate_All (Gtk.Handlers);
procedure Greyscale is
Win : Gtk_Window;
Width : constant := 640;
Height : const... |
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... | #Common_Lisp | Common Lisp |
(defun guess-the-number (&optional (max 1000) (min 0))
(flet ((get-feedback (guess)
(loop
initially (format t "I choose ~a.~%" guess)
for answer = (read)
if (member answer '(greater lower correct))
return answer
else do (write-line "An... |
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... | #Bori | Bori | bool isHappy (int n)
{
ints cache;
while (n != 1)
{
int sum = 0;
if (cache.contains(n))
return false;
cache.add(n);
while (n != 0)
{
int digit = n % 10;
sum += (digit * digit);
n = (int)(n / 10);
}
n = sum;
}
return true;... |
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... | #FreeBASIC | FreeBASIC | ' version 09-10-2016
' compile with: fbc -s console
' Nashville International Airport (BNA) in Nashville, TN, USA,
' N 36°07.2', W 86°40.2' (36.12, -86.67)
' Los Angeles International Airport (LAX) in Los Angeles, CA, USA,
' N 33°56.4', W 118°24.0' (33.94, -118.40).
' 6372.8 km is an approximation of the radius o... |
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
| #Ra | Ra |
class HelloWorld
**Prints "Goodbye, World!" without a new line**
on start
print "Goodbye, World!" without new line
|
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
| #Racket | Racket | #lang racket
(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
| #Raku | Raku | print "Goodbye, World!";
printf "%s", "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
| #RASEL | RASEL | "!dlroW ,olleH">:?@,Gj |
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
| #Fhidwfe | Fhidwfe | puts$ "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
| #Prolog | Prolog | % this one with side effect hash table creation
:-dynamic hash/2.
make_hash([],[]).
make_hash([H|Q],[H1|Q1]):-
assert(hash(H,H1)),
make_hash(Q,Q1).
:-make_hash([un,deux,trois],[[a,b,c],[d,e,f],[g,h,i]])
% this one without side effects
make_hash_pure([],[],[]).
make_hash_pure([H|Q],[H1|Q1],[hash(H,H1)|R])... |
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/... | #JavaScript | JavaScript | function isHarshad(n) {
var s = 0;
var n_str = new String(n);
for (var i = 0; i < n_str.length; ++i) {
s += parseInt(n_str.charAt(i));
}
return n % s === 0;
}
var count = 0;
var harshads = [];
for (var n = 1; count < 20; ++n) {
if (isHarshad(n)) {
count++;
harshads.pu... |
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
| #Elena | Elena | import forms;
public class MainWindow : SDIDialog
{
Label goodByeWorldLabel;
Button closeButton;
constructor new()
<= new()
{
self.Caption := "ELENA";
goodByeWorldLabel := Label.new();
closeButton := Button.new();
self
.appendControl(goodB... |
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
| #Euphoria | Euphoria | include msgbox.e
integer response
response = message_box("Goodbye, World!","Bye",MB_OK) |
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... | #Delphi | Delphi | FILE: Unit1.pas |
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... | #Echolisp | Echolisp |
(require 'interface)
;; helper new button with text
(define (ui-add-button text)
(define b (ui-create-element "button" '((type "button"))))
(ui-set-html b text)
(ui-add b))
(define (panel )
(ui-clear)
(info-text "My rosetta application" "blue")
;; input field (checked for numeric)
(def... |
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... | #Maple | Maple |
Increase();
|
http://rosettacode.org/wiki/Guess_the_number/With_feedback | Guess the number/With feedback | Task
Write a game (computer program) that follows the following rules:
The computer chooses a number between given set limits.
The player is asked for repeated guesses until the the target number is guessed correctly
At each guess, the computer responds with whether the guess is:
higher than the target,
equal to... | #Ada | Ada | with Ada.Numerics.Discrete_Random;
with Ada.Text_IO;
procedure Guess_Number_Feedback is
function Get_Int (Prompt : in String) return Integer is
begin
loop
Ada.Text_IO.Put (Prompt);
declare
Response : constant String := Ada.Text_IO.Get_Line;
begin
if Respons... |
http://rosettacode.org/wiki/Greyscale_bars/Display | Greyscale bars/Display | The task is to display a series of vertical greyscale bars (contrast bars) with a sufficient number of bars to span the entire width of the display.
For the top quarter of the display, the left hand bar should be black, and we then incrementally step through six shades of grey until we have a white bar on the right ha... | #Amazing_Hopper | Amazing Hopper |
#include <flow.h>
#include <flow-term.h>
#define SPACE(_T_,_N_) REPLICATE( " ", {_T_}DIV-INTO(_N_) )
DEF-MAIN(argv,argc)
CLR-SCR
GOSUB( Print Grey Scale )
END
RUTINES
DEF-FUN( Print Grey Scale )
SET( nrcolors, 8 )
SET( direction, 1 )
MSET( quarter, color )
LOCATE( 0, 0 )
FOR( LT?( quarter, ... |
http://rosettacode.org/wiki/Greyscale_bars/Display | Greyscale bars/Display | The task is to display a series of vertical greyscale bars (contrast bars) with a sufficient number of bars to span the entire width of the display.
For the top quarter of the display, the left hand bar should be black, and we then incrementally step through six shades of grey until we have a white bar on the right ha... | #ANSI_Standard_BASIC | ANSI Standard BASIC | 100 SET WINDOW 0,1279,0,1023
110 REM (0,0) is the bottom left of the display
120 SET AREA COLOR 1 ! Select color one for drawing
130 FOR row=1 TO 4
140 LET n=IP(2^(row+2))
150 LET w=IP(1280/n)
160 LET py=IP(256*(4-row))
170 FOR b=0 TO n-1
180 LET g=b/(n-1)
190 IF n=16 OR n=64 THEN LET g=1-g
200 ... |
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... | #D | D | import std.stdio, std.string;
void main() {
immutable mnOrig = 1, mxOrig = 10;
int mn = mnOrig, mx = mxOrig;
writefln(
"Think of a number between %d and %d 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... |
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... | #BQN | BQN | SumSqDgt ← +´2⋆˜ •Fmt-'0'˙
Happy ← ⟨⟩{𝕨((⊑∊˜ )◶⟨∾𝕊(SumSqDgt⊢),1=⊢⟩)𝕩}⊢
8↑Happy¨⊸/↕50 |
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... | #Frink | Frink | haversine[theta] := (1-cos[theta])/2
dist[lat1, long1, lat2, long2] := 2 earthradius arcsin[sqrt[haversine[lat2-lat1] + cos[lat1] cos[lat2] haversine[long2-long1]]]
d = dist[36.12 deg, -86.67 deg, 33.94 deg, -118.40 deg]
println[d-> "km"] |
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... | #FunL | FunL | import math.*
def haversin( theta ) = (1 - cos( theta ))/2
def radians( deg ) = deg Pi/180
def haversine( (lat1, lon1), (lat2, lon2) ) =
R = 6372.8
h = haversin( radians(lat2 - lat1) ) + cos( radians(lat1) ) cos( radians(lat2) ) haversin( radians(lon2 - lon1) )
2R asin( sqrt(h) )
println( haversine((36.12... |
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
| #REBOL | REBOL | prin "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
| #Red | Red | prin "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
| #Retro | Retro | 'Goodbye,_World! s:put |
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
| #REXX | REXX | /*REXX pgm displays a "Goodbye, World!" without a trailing newline. */
call charout ,'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
| #Fish | Fish | !v"Hello world!"r!
>l?!;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
| #PureBasic | PureBasic | Dim keys.s(3)
Dim vals.s(3)
NewMap Hash.s()
keys(0)="a" : keys(1)="b" : keys(2)="c" : keys(3)="d"
vals(0)="1" : vals(1)="2" : vals(2)="3" : vals(3)="4"
For n = 0 To 3
Hash(keys(n))= vals(n)
Next
ForEach Hash()
Debug Hash()
Next |
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
| #Python | Python | keys = ['a', 'b', 'c']
values = [1, 2, 3]
hash = {key: value for key, value in 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/... | #jq | jq | def is_harshad:
def digits: tostring | [explode[] | ([.]| implode) | tonumber];
if . >= 1 then (. % (digits|add)) == 0
else false
end ;
# produce a stream of n Harshad numbers
def harshads(n):
# [candidate, count]
def _harshads:
if .[0]|is_harshad then .[0], ([.[0]+1, .[1]-1]| _harshads)
elif .[1] > 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
| #F.23 | F# | #light
open System
open System.Windows.Forms
[<EntryPoint>]
let main _ =
MessageBox.Show("Hello World!") |> ignore
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
| #Factor | Factor | USING: ui ui.gadgets.labels ;
[ "Goodbye World" <label> "Rosetta Window" open-window ] with-ui
|
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... | #Elena | Elena | import forms;
import extensions;
public class MainWindow : SDIDialog
{
Button btmIncrement;
Button btmRandom;
Edit txtNumber;
constructor new()
<= new()
{
btmIncrement := Button.new();
btmRandom := Button.new();
txtNumber := Edit.new();
self
... |
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... | #Euphoria | Euphoria |
include GtkEngine.e -- see OpenEuphoria.org
constant -- interface
win = create(GtkWindow,"title=GUI Component Interaction;size=200x100;border=10;$destroy=Quit"),
pan = create(GtkBox,"orientation=vertical;spacing=10"),
inp = create(GtkEntry,"name=Input;text=0;$activate=Validate"),
box = create(GtkBut... |
http://rosettacode.org/wiki/Guess_the_number | Guess the number | Task
Write a program where the program chooses a number between 1 and 10.
A player is then prompted to enter a guess. If the player guesses wrong, then the prompt appears again until the guess is correct.
When the player has made a successful guess the computer will issue a "Well guessed!" message, a... | #11l | 11l | V t = random:(1..10)
V g = Int(input(‘Guess a number that's between 1 and 10: ’))
L t != g
g = Int(input(‘Guess again! ’))
print(‘That's right!’) |
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... | #Mathematica.2FWolfram_Language | Mathematica/Wolfram Language | Manipulate[Null, {{value, 0},
InputField[Dynamic[value], Number,
Enabled -> Dynamic[value == 0]] &},
Row@{Button["increment", value++, Enabled -> Dynamic[value < 10]],
Button["decrement", value--, Enabled -> Dynamic[value > 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... | #NewLISP | NewLISP | ; file: gui-enable.lsp
; url: http://rosettacode.org/wiki/GUI_enabling/disabling_of_controls
; author: oofoe 2012-02-02
; Load library and initialize GUI server:
(load (append (env "NEWLISPDIR") "/guiserver.lsp"))
(gs:init)
; The "interlock" function maintains GUI consistency by disabling all
; controls, then ... |
http://rosettacode.org/wiki/Guess_the_number/With_feedback | Guess the number/With feedback | Task
Write a game (computer program) that follows the following rules:
The computer chooses a number between given set limits.
The player is asked for repeated guesses until the the target number is guessed correctly
At each guess, the computer responds with whether the guess is:
higher than the target,
equal to... | #ALGOL_68 | ALGOL 68 | # simple guess-the-number game #
main:(
BOOL valid input := TRUE;
# register an error handler so we can detect and recover from #
# invalid input #
on value error( stand in
, ( REF FILE f )BOOL:
BEGIN
valid input := FALSE;
... |
http://rosettacode.org/wiki/Greyscale_bars/Display | Greyscale bars/Display | The task is to display a series of vertical greyscale bars (contrast bars) with a sufficient number of bars to span the entire width of the display.
For the top quarter of the display, the left hand bar should be black, and we then incrementally step through six shades of grey until we have a white bar on the right ha... | #AutoHotkey | AutoHotkey | h := A_ScreenHeight
w := A_ScreenWidth
pToken := gdip_Startup()
hdc := CreateCompatibleDC()
hbm := CreateDIBSection(w, h)
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
OnExit, Exit
Gui +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
hwnd := WinExist()
Gui Show, NA
columnHeight := h/4
Loop 4
... |
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... | #Delphi | Delphi |
program Guess_the_number;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
system.console;
type
TCharSet = set of char;
var
PlayerNumber, CPUNumber: word;
CPULow: word = 0;
CPUHi: word = 1000;
PlayerLow: word = 0;
PlayerHi: word = 1000;
CPUWin, PlayerWin: boolean;
CPUGuessList: string = 'Previus g... |
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... | #Brat | Brat | include :set
happiness = set.new 1
sadness = set.new
sum_of_squares_of_digits = { num |
num.to_s.dice.reduce 0 { sum, n | sum = sum + n.to_i ^ 2 }
}
happy? = { n, seen = set.new |
when {true? happiness.include? n } { happiness.merge seen << n; true }
{ true? sadness.include? n } { sadness.merge seen; fals... |
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... | #FutureBasic | FutureBasic | window 1
local fn Haversine( lat1 as double, lon1 as double, lat2 as double, lon2 as double, miles as ^double, kilometers as ^double )
double deg2rad, dLat, dLon, a, c, earth_radius_miles, earth_radius_kilometers
earth_radius_miles = 3959.0 // Radius of the Earth in miles
earth_radius_kilometers = 6372.8 // R... |
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... | #Go | Go | package main
import (
"fmt"
"math"
)
func haversine(θ float64) float64 {
return .5 * (1 - math.Cos(θ))
}
type pos struct {
φ float64 // latitude, radians
ψ float64 // longitude, radians
}
func degPos(lat, lon float64) pos {
return pos{lat * math.Pi / 180, lon * math.Pi / 180}
}
const 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
| #Ring | Ring | see "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
| #Ruby | Ruby | 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
| #Run_BASIC | Run BASIC | 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
| #Rust | Rust | fn main () {
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
| #FOCAL | FOCAL | TYPE "Hello, world" ! |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.