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/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Lasso | Lasso | // Define the thread if it doesn't exist
// New definition supersede any current threads.
not ::serverwide_singleton->istype
? define serverwide_singleton => thread {
data public switch = 'x'
}
local(
a = serverwide_singleton,
b = serverwide_singleton,
)
#a->switch = 'a'
#b->switch = 'b'
#a->switch... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Latitude | Latitude | Singleton ::= Object clone tap {
self id := 0.
self newID := {
self id := self id + 1.
}.
self clone := {
err ArgError clone tap { self message := "Singleton object!". } throw.
}.
}.
println: Singleton newID. ; 1
println: Singleton newID. ; 2
println: Singleton newID. ; 3 |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #Racket | Racket |
#lang racket
(define (bubble-sort <? v)
(define len (vector-length v))
(define ref vector-ref)
(let loop ([max len]
[again? #f])
(for ([i (in-range 0 (- max 1))]
[j (in-range 1 max)])
(define vi (ref v i))
(when (<? (ref v j) vi)
(vector-set! v i (ref v j))
... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Lingo | Lingo | -- parent script "SingletonDemo"
property _instance
property _someProperty
----------------------------------------
-- @constructor
----------------------------------------
on new (me)
if not voidP(me.script._instance) then return me.script._instance
me.script._instance = me
me._someProperty = 0
return me
e... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Logtalk | Logtalk | :- object(singleton).
:- public(value/1).
value(Value) :-
state(Value).
:- public(set_value/1).
set_value(Value) :-
retract(state(_)),
assertz(state(Value)).
:- private(state/1).
:- dynamic(state/1).
state(0).
:- end_object. |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #Raku | Raku | sub bubble_sort (@a) {
for ^@a -> $i {
for $i ^..^ @a -> $j {
@a[$j] < @a[$i] and @a[$i, $j] = @a[$j, $i];
}
}
} |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #NetRexx | NetRexx | /* NetRexx */
options replace format comments java crossref symbols binary
import java.util.random
class RCSingleton public
method main(args = String[]) public static
RCSingleton.Testcase.main(args)
return
-- ---------------------------------------------------------------------------
class RCSingl... |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #REALbasic | REALbasic |
Dim sortable() As Integer = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
sortable.Shuffle() ' sortable is now randomized
Dim swapped As Boolean
Do
Dim index, bound As Integer
bound = sortable.Ubound
While index < bound
If sortable(index) > sortable(index + 1) Then
Dim s As Integer = sortab... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Nim | Nim | type Singleton = object # Singleton* would export
foo*: int
var single* = Singleton(foo: 0) |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Objeck | Objeck | class Singleton {
@singleton : static : Singleton;
New : private () {
}
function : GetInstance() ~ Singleton {
if(@singleton <> Nil) {
@singleton := Singleton->New();
};
return @singleton;
}
method : public : DoStuff() ~ Nil {
...
}
} |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #AutoHotkey | AutoHotkey | run, cmd /k
WinWait, ahk_class ConsoleWindowClass
controlsend, ,hello console, ahk_class ConsoleWindowClass |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #AutoHotkey | AutoHotkey | WinActivate, ahk_class MozillaUIWindowClass
Click 200, 200 right ; relative to external window (firefox)
sleep, 2000
WinMinimize
CoordMode, Mouse, Screen
Click 400, 400 right ; relative to top left corner of the screen. | |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #REXX | REXX | /*REXX program sorts an array (of any kind of items) using the bubble─sort algorithm.*/
call gen /*generate the array elements (items).*/
call show 'before sort' /*show the before array elements. */
say copies('▒', 70) ... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Objective-C | Objective-C | // SomeSingleton.h
@interface SomeSingleton : NSObject
{
// any instance variables
}
+ (SomeSingleton *)sharedInstance;
@end |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Oforth | Oforth | Object Class new: Sequence(channel)
Sequence method: initialize(initialValue)
Channel newSize(1) := channel
@channel send(initialValue) drop ;
Sequence method: nextValue @channel receive dup 1 + @channel send drop ; |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #AutoIt | AutoIt | Run("notepad")
WinWaitActive("Untitled - Notepad")
Send("The answer is 42") |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #BASIC | BASIC | 100 REM SIMULATE KEYBORD INPUT
110 GOSUB 170"OPEN&WRITE KB
120 PRINT "HOME:RUN140"M$"MARK
130 PRINT D$C$A$"EXEC"F$: END
140 INPUT "NAME? ";N$
150 PRINT "HELLO, "N$"!"
160 END
170 D$ = CHR$ (4):C$ = "CLOSE"
180 M$ = CHR$ (13):O$ = "OPEN"
190 F$ = "KB":A$ = F$ + M$ + D$
200 PRINT D$"MON I"M$D$O$;
... |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #C | C |
#define WINVER 0x500
#include<windows.h>
int main()
{
int maxX = GetSystemMetrics(SM_CXSCREEN), maxY = GetSystemMetrics(SM_CYSCREEN);
int x = maxX/2, y = maxY/2;
double factorX = 65536.0 / maxX,factorY = 65536.0 / maxY;
INPUT ip;
ZeroMemory(&ip,sizeof(ip));
ip.type = INPUT_MOUSE;
while(x > 5 || y < m... | |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #Ring | Ring | bubbleList = [4,2,1,3]
flag = 0
bubbleSort(bubbleList)
see bubbleList
func bubbleSort A
n = len(A)
while flag = 0
flag = 1
for i = 1 to n-1
if A[i] > A[i+1]
temp = A[i]
A[i] = A[i+1]
A[i+1] = temp
f... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #ooRexx | ooRexx |
a = .singleton~new
b = .singleton~new
a~foo = "Rick"
if a~foo \== b~foo then say "A and B are not the same object"
::class singleton
-- initialization method for the class
::method init class
expose singleton
-- mark this as unallocated. We could also just allocate
-- the singleton now, but better practice... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #OxygenBasic | OxygenBasic |
Class Singleton
static sys inst 'private
int instantiated() { return inst }
void constructor(){ if not inst then inst=@this }
'all other methods start with @this=inst
end class
'if not singleton.instantiated
new Singleton MySingleton
'endif
|
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #C | C | gcc -o simkeypress -L/usr/X11R6/lib -lX11 simkeypress.c
|
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #Clojure | Clojure | (import java.awt.Robot)
(import java.awt.event.KeyEvent)
(defn keytype [str]
(let [robot (new Robot)]
(doseq [ch str]
(if (Character/isUpperCase ch)
(doto robot
(.keyPress (. KeyEvent VK_SHIFT))
(.keyPress (int ch))
(.keyRelease (int ch))
(.keyRelease (. KeyEvent VK_SHIFT)))
(let [u... |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #Common_Lisp | Common Lisp |
(defun sh (cmd)
#+clisp (shell cmd)
#+ecl (si:system cmd)
#+sbcl (sb-ext:run-program "/bin/sh" (list "-c" cmd) :input nil :output *standard-output*)
#+clozure (ccl:run-program "/bin/sh" (list "-c" cmd) :input nil :output *standard-output*))
(sh "xdotool mousemove 0 0 click 1")
(sleep 2)
(sh "xdotool mousemove 300 300... | |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #Fantom | Fantom |
using fwt
using gfx
class Main
{
public static Void main ()
{
button1 := Button
{
text = "don't click!"
onAction.add |Event e|
{
echo ("clicked by code")
}
}
button2 := Button
{
text = "click"
onAction.add |Event e|
{
// fire all ... | |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #Ruby | Ruby | class Array
def bubblesort1!
length.times do |j|
for i in 1...(length - j)
if self[i] < self[i - 1]
self[i], self[i - 1] = self[i - 1], self[i]
end
end
end
self
end
def bubblesort2!
each_index do |index|
(length - 1).downto( index ) do |i|
self[... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Oz | Oz | declare
local
class Singleton
meth init
skip
end
end
L = {NewLock}
Instance
in
fun {GetInstance}
lock L then
if {IsFree Instance} then
Instance = {New Singleton init}
end
Instance
end
end
end |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #Go | Go | package main
import (
"github.com/micmonay/keybd_event"
"log"
"runtime"
"time"
)
func main() {
kb, err := keybd_event.NewKeyBonding()
if err != nil {
log.Fatal(err)
}
// For linux, need to wait 2 seconds
if runtime.GOOS == "linux" {
time.Sleep(2 * time.Second)
... |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #FreeBASIC | FreeBASIC | #include "fbgfx.bi"
#define rect 4
Windowtitle "Mouse events"
Screen 19,32
Dim Shared As Integer xres, yres
Screeninfo xres, yres
Type box
As Single x, y, z
As String caption
As Uinteger textcol, boxcol
End Type
Dim Shared As box label(rect,1)
Dim Shared As box button(rect,1)
Dim Shared As Boolean fla... | |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #Run_BASIC | Run BASIC | siz = 100
dim data$(siz)
unSorted = 1
WHILE unSorted
unSorted = 0
FOR i = 1 TO siz -1
IF data$(i) > data$(i + 1) THEN
tmp = data$(i)
data$(i) = data$(i + 1)
data$(i + 1) = tmp
unSorted = 1
END IF
NEXT
WEND |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Perl | Perl | package Singleton;
use strict;
use warnings;
my $Instance;
sub new {
my $class = shift;
$Instance ||= bless {}, $class; # initialised once only
}
sub name {
my $self = shift;
$self->{name};
}
sub set_name {
my ($self, $name) = @_;
$self->{name} = $name;
}
package main;
my $s1 = Singl... |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #GUISS | GUISS | Start,Programs,Accessories,Notepad,Textbox,Type:Hello World[pling] |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #Java | Java | import java.awt.Robot
public static void type(String str){
Robot robot = new Robot();
for(char ch:str.toCharArray()){
if(Character.isUpperCase(ch)){
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress((int)ch);
robot.keyRelease((int)ch);
robot.keyRelease(KeyEvent.VK_SHIFT);... |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #Go | Go | package main
import "github.com/go-vgo/robotgo"
func main() {
robotgo.MouseClick("left", false) // single clicks left mouse button
robotgo.MouseClick("right", true) // double clicks right mouse button
} | |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #GUISS | GUISS | Start,Programs,Accessories,Notepad,Textbox,Type:Hello World[pling],Menu:File,Save,
Inputbox:filename>greetings.txt,Button:Save | |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #Rust | Rust | fn bubble_sort<T: Ord>(values: &mut[T]) {
let mut n = values.len();
let mut swapped = true;
while swapped {
swapped = false;
for i in 1..n {
if values[i - 1] > values[i] {
values.swap(i - 1, i);
swapped = true;
}
}
... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Phix | Phix | -- <separate include file>
object chk = NULL
class singleton
public procedure check()
if chk==NULL then
chk = this
elsif this!=chk then
?9/0
end if
?"ok"
end procedure
end class
global singleton s = new()
--global singleton s2 = new()
-- </separate inclu... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #PHP | PHP | class Singleton {
protected static $instance = null;
public $test_var;
private function __construct(){
//Any constructor code
}
public static function getInstance(){
if (is_null(self::$instance)){
self::$instance = new self();
}
return self::$instance;
}
}
$foo = Singleton::getInstan... |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #Kotlin | Kotlin | // version 1.1.2
import java.awt.Robot
import java.awt.event.KeyEvent
fun sendChars(s: String, pressReturn: Boolean = true) {
val r = Robot()
for (c in s) {
val ci = c.toUpperCase().toInt()
r.keyPress(ci)
r.keyRelease(ci)
}
if (pressReturn) {
r.keyPress(KeyEvent.VK_EN... |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #LabVIEW | LabVIEW | when defined(windows):
import winlean
else:
{.error: "not supported os".}
type
InputType = enum
itMouse itKeyboard itHardware
KeyEvent = enum
keExtendedKey = 0x0001
keKeyUp = 0x0002
keUnicode = 0x0004
keScanCode = 0x0008
MouseInput {.importc: "MOUSEINPUT".} = object
dx, dy: clong... |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #Java | Java | Point p = component.getLocation();
Robot robot = new Robot();
robot.mouseMove(p.getX(), p.getY()); //you may want to move a few pixels closer to the center by adding to these values
robot.mousePress(InputEvent.BUTTON1_MASK); //BUTTON1_MASK is the left button,
//BUTTON2_MASK is the... | |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #Julia | Julia |
# Wrap win32 API function mouse_event() from the User32 dll.
function mouse_event_wrapper(dwFlags,dx,dy,dwData,dwExtraInfo)
ccall((:mouse_event, "User32"),stdcall,Nothing,(UInt32,UInt32,UInt32,UInt32,UInt),dwFlags,dx,dy,dwData,dwExtraInfo)
end
function click()
mouse_event_wrapper(0x2,0,0,0,0)
mouse_even... | |
http://rosettacode.org/wiki/Singly-linked_list/Element_definition | Singly-linked list/Element definition | singly-linked list
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked list: Element definition, Element insertion, Lis... | #360_Assembly | 360 Assembly | * Singly-linked list/Element definition 07/02/2017
LISTSINA CSECT
USING LISTSINA,R13 base register
B 72(R15) skip savearea
DC 17F'0' savearea
STM R14,R12,12(R13) prolog
ST R13,4(R15) " <-
ST R15,8(... |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #Sather | Sather | class SORT{T < $IS_LT{T}} is
private swap(inout a, inout b:T) is
temp ::= a;
a := b;
b := temp;
end;
bubble_sort(inout a:ARRAY{T}) is
i:INT;
if a.size < 2 then return; end;
loop
sorted ::= true;
loop i := 0.upto!(a.size - 2);
if a[i+1] < a[i] then
swap(inout a... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #PicoLisp | PicoLisp | (class +Singleton)
(dm message1> ()
(prinl "This is method 1 on " This) )
(dm message2> ()
(prinl "This is method 2 on " This) ) |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #PureBasic | PureBasic | Global SingletonSemaphore=CreateSemaphore(1)
Interface OO_Interface ; Interface for any value of this type
Get.i()
Set(Value.i)
Destroy()
EndInterface
Structure OO_Structure ; The *VTable structure
Get.i
Set.i
Destroy.i
EndStructure
Structure OO_Var
*VirtualTable.OO_Structure
Va... |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #Nim | Nim | when defined(windows):
import winlean
else:
{.error: "not supported os".}
type
InputType = enum
itMouse itKeyboard itHardware
KeyEvent = enum
keExtendedKey = 0x0001
keKeyUp = 0x0002
keUnicode = 0x0004
keScanCode = 0x0008
MouseInput {.importc: "MOUSEINPUT".} = object
dx, dy: clong... |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #OCaml | OCaml | ocaml -I +Xlib Xlib.cma keysym.cma send_event.ml
|
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #Kotlin | Kotlin | // version 1.1.2
import java.awt.Robot
import java.awt.event.InputEvent
fun sendClick(buttons: Int) {
val r = Robot()
r.mousePress(buttons)
r.mouseRelease(buttons)
}
fun main(args: Array<String>) {
sendClick(InputEvent.BUTTON3_DOWN_MASK) // simulate a click of the mouse's right button
}
| |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #Oz | Oz | declare
[QTk] = {Module.link ['x-oz://system/wp/QTk.ozf']}
Button
Window = {QTk.build td(button(text:"Click me" handle:Button))}
in
{Window show}
{Delay 500}
{Tk.send event(generate Button "<ButtonPress-1>")}
{Delay 500}
{Tk.send event(generate Button "<ButtonRelease-1>")} | |
http://rosettacode.org/wiki/Singly-linked_list/Element_definition | Singly-linked list/Element definition | singly-linked list
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked list: Element definition, Element insertion, Lis... | #AArch64_Assembly | AArch64 Assembly |
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program defList.s */
/*******************************************/
/* Constantes file */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.... |
http://rosettacode.org/wiki/Singly-linked_list/Element_definition | Singly-linked list/Element definition | singly-linked list
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked list: Element definition, Element insertion, Lis... | #ACL2 | ACL2 | (let ((elem 8)
(next (list 6 7 5 3 0 9)))
(cons elem next)) |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #Scala | Scala | def bubbleSort[T](arr: Array[T])(implicit o: Ordering[T]) {
import o._
val consecutiveIndices = (arr.indices, arr.indices drop 1).zipped
var hasChanged = true
do {
hasChanged = false
consecutiveIndices foreach { (i1, i2) =>
if (arr(i1) > arr(i2)) {
hasChanged = true
val tmp = arr(i... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Python | Python | >>> class Borg(object):
__state = {}
def __init__(self):
self.__dict__ = self.__state
# Any other class names/methods
>>> b1 = Borg()
>>> b2 = Borg()
>>> b1 is b2
False
>>> b1.datum = range(5)
>>> b1.datum
[0, 1, 2, 3, 4]
>>> b2.datum
[0, 1, 2, 3, 4]
>>> b1.datum is b2.datum
True
>>> # For any datum! |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Racket | Racket |
#lang racket
(provide instance)
(define singleton%
(class object%
(super-new)))
(define instance (new singleton%))
|
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #Oz | Oz | declare
[QTk] = {Module.link ['x-oz://system/wp/QTk.ozf']}
Entry
Window = {QTk.build td(entry(handle:Entry))}
in
{Window show}
{Entry getFocus(force:true)}
for C in "Hello, world!" do
Key = if C == 32 then "<space>" else [C] end
in
{Delay 100}
{Tk.send event(generate Entry Key)}
end |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #Perl | Perl | $target = "/dev/pts/51";
### How to get the correct value for $TIOCSTI is discussed here : http://www.perlmonks.org/?node_id=10920
$TIOCSTI = 0x5412 ;
open(TTY,">$target") or die "cannot open $target" ;
$b="sleep 99334 &\015";
@c=split("",$b);
sleep(2);
foreach $a ( @c ) { ioctl(TTY,$TIOCSTI,$a); select(undef,und... |
http://rosettacode.org/wiki/Simple_turtle_graphics | Simple turtle graphics | The first turtle graphic discussed in Mindstorms: Children, Computers, and Powerful Ideas by Seymour Papert is a simple drawing of a house. It is a square with a triangle on top for the roof.
For a slightly more advanced audience, a more practical introduction to turtle graphics might be to draw a bar chart.
See imag... | #Action.21 | Action! | INCLUDE "D2:TURTLE.ACT" ;from the Action! Tool Kit
PROC Rectangle(INT w,h)
BYTE i
FOR i=1 TO 2
DO
Forward(h)
Left(90)
Forward(w)
Left(90)
OD
RETURN
PROC Square(INT w)
Rectangle(w,w)
RETURN
PROC Triangle(INT w)
BYTE i
FOR i=1 TO 3
DO
Forward(w)
Right(120)
OD
RETURN
P... |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #Phix | Phix | --
-- demo\rosetta\Simulate_mouse_input.exw
--
-- Note that CURSORPOS, SCREENPOSITION, and MOUSEBUTTON are known to be a little flaky and/or system-dependent, ymmv.
--
without js -- you'd better hope this sort of thing ain't possible in a browser!
requires("1.0.1") -- (IupGetGlobalIntInt)
include pGUI.e
include timedat... | |
http://rosettacode.org/wiki/Singly-linked_list/Element_definition | Singly-linked list/Element definition | singly-linked list
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked list: Element definition, Element insertion, Lis... | #Action.21 | Action! | DEFINE PTR="CARD"
TYPE ListNode=[
BYTE data
PTR nxt] |
http://rosettacode.org/wiki/Singly-linked_list/Element_definition | Singly-linked list/Element definition | singly-linked list
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked list: Element definition, Element insertion, Lis... | #ActionScript | ActionScript | package
{
public class Node
{
public var data:Object = null;
public var link:Node = null;
public function Node(obj:Object)
{
data = obj;
}
}
} |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #Scheme | Scheme | (define (bubble-sort x gt?)
(letrec
((fix (lambda (f i)
(if (equal? i (f i))
i
(fix f (f i)))))
(sort-step (lambda (l)
(if (or (null? l) (null? (cdr l)))
l
(if (gt? (car l) (cadr l))
(cons (cadr l) (sort-step (cons (car l) (cddr l... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Raku | Raku | class Singleton {
# We create a lexical variable in the class block that holds our single instance.
my Singleton $instance = Singleton.bless; # You can add initialization arguments here.
method new {!!!} # Singleton.new dies.
method instance { $instance; }
} |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #Phix | Phix | --
-- demo\rosetta\Simulate_keyboard_input.exw
--
without js -- you'd better hope this sort of thing ain't possible in a browser!
include pGUI.e
string hw = "Look ma no hands! "
function timer_cb(Ihandle ih)
if length(hw) then
IupSetGlobalInt("KEY",hw[1])
hw = hw[2..$]
else
IupSetInt... |
http://rosettacode.org/wiki/Simple_turtle_graphics | Simple turtle graphics | The first turtle graphic discussed in Mindstorms: Children, Computers, and Powerful Ideas by Seymour Papert is a simple drawing of a house. It is a square with a triangle on top for the roof.
For a slightly more advanced audience, a more practical introduction to turtle graphics might be to draw a bar chart.
See imag... | #Ada | Ada |
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters; use Ada.Characters;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Strings; use Ada.Strings;
-- procedure main - begins program execution
procedure main is
type Sketch_Pad is array(1 .. 50, 1 .. 50) of Character;
thePen : Boolean := True; ... |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #PicoLisp | PicoLisp | (load "@lib/http.l" "@lib/scrape.l")
# Connect to the demo app at https://7fach.de/app/
(scrape "7fach.de" 80 "app")
# Log in
(expect "'admin' logged in"
(enter 3 "admin") # Enter user name into 3rd field
(enter 4 "admin") # Enter password into 4th field
(press "login") ) # Press the "log... | |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #PureBasic | PureBasic | Macro Click()
mouse_event_(#MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event_(#MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
EndMacro
; Click at the current location
Click()
Delay(1000) ; Wait a second
; Move to a new location and click it
SetCursorPos_(50, 50)
Click() | |
http://rosettacode.org/wiki/Singly-linked_list/Element_definition | Singly-linked list/Element definition | singly-linked list
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked list: Element definition, Element insertion, Lis... | #Ada | Ada | type Link;
type Link_Access is access Link;
type Link is record
Next : Link_Access := null;
Data : Integer;
end record; |
http://rosettacode.org/wiki/Singly-linked_list/Element_definition | Singly-linked list/Element definition | singly-linked list
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked list: Element definition, Element insertion, Lis... | #ALGOL_68 | ALGOL 68 | # -*- coding: utf-8 -*- #
CO REQUIRES:
MODE OBJVALUE = ~ # Mode/type of actual obj to be stacked #
END CO
MODE OBJNEXTLINK = STRUCT(
REF OBJNEXTLINK next,
OBJVALUE value # ... etc. required #
);
PROC obj nextlink new = REF OBJNEXTLINK:
HEAP OBJNEXTLINK;
PROC obj nextlink free = (REF OBJNEXTLINK free)VOID:... |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #Scilab | Scilab | function b=BubbleSort(a)
n=length(a)
swapped=%T
while swapped
swapped=%F
for i=1:1:n-1
if a(i)>a(i+1) then
temp=a(i)
a(i)=a(i+1)
a(i+1)=temp
swapped=%T
end
end
end
b=a
endfunction BubbleSort |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Ruby | Ruby | require 'singleton'
class MySingleton
include Singleton
# constructor and/or methods go here
end
a = MySingleton.instance # instance is only created the first time it is requested
b = MySingleton.instance
puts a.equal?(b) # outputs "true" |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Scala | Scala | object Singleton {
// any code here gets executed as if in a constructor
} |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #PicoLisp | PicoLisp | (load "@lib/http.l" "@lib/scrape.l")
# Connect to the demo app at http://7fach.de/8080
(scrape "7fach.de" 80 "8080")
# Log in
(expect "'admin' logged in"
(enter 3 "admin") # Enter user name into 3rd field
(enter 4 "admin") # Enter password into 4th field
(press "login") ) # Press the "log... |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #PowerShell | PowerShell |
Add-Type -AssemblyName Microsoft.VisualBasic
Add-Type -AssemblyName System.Windows.Forms
calc.exe
Start-Sleep -Milliseconds 300
[Microsoft.VisualBasic.Interaction]::AppActivate(“Calc”)
[System.Windows.Forms.SendKeys]::SendWait(“2{ADD}2=”)
|
http://rosettacode.org/wiki/Simple_turtle_graphics | Simple turtle graphics | The first turtle graphic discussed in Mindstorms: Children, Computers, and Powerful Ideas by Seymour Papert is a simple drawing of a house. It is a square with a triangle on top for the roof.
For a slightly more advanced audience, a more practical introduction to turtle graphics might be to draw a bar chart.
See imag... | #J | J | ;install each cut 'gl2 gles github:zerowords/tgsjo' |
http://rosettacode.org/wiki/Simple_turtle_graphics | Simple turtle graphics | The first turtle graphic discussed in Mindstorms: Children, Computers, and Powerful Ideas by Seymour Papert is a simple drawing of a house. It is a square with a triangle on top for the roof.
For a slightly more advanced audience, a more practical introduction to turtle graphics might be to draw a bar chart.
See imag... | #Julia | Julia | using Luxor, Colors
function house(🐢, x, y, siz)
oldorientation = 🐢.orientation
xpos, ypos = 🐢.xpos, 🐢.ypos
# house wall
Reposition(🐢, x, y)
Rectangle(🐢, siz, siz)
# roof
Reposition(🐢, x - siz / 2, y - siz / 2)
Turn(🐢, -60)
Forward(🐢, siz)
Turn(🐢, 120)
Forward(🐢... |
http://rosettacode.org/wiki/Simple_turtle_graphics | Simple turtle graphics | The first turtle graphic discussed in Mindstorms: Children, Computers, and Powerful Ideas by Seymour Papert is a simple drawing of a house. It is a square with a triangle on top for the roof.
For a slightly more advanced audience, a more practical introduction to turtle graphics might be to draw a bar chart.
See imag... | #Logo | Logo | to rectangle :width :height
repeat 2 [
forward :height
left 90
forward :width
left 90 ]
end
to square :size
rectangle size size
end
to triangle :size
repeat 3 [
forward size
right 120 ]
end
to house :size
left 90
square size
... |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #Python | Python | import ctypes
def click():
ctypes.windll.user32.mouse_event(0x2, 0,0,0,0) # Mouse LClick Down, relative coords, dx=0, dy=0
ctypes.windll.user32.mouse_event(0x4, 0,0,0,0) # Mouse LClick Up, relative coords, dx=0, dy=0
click() | |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #Racket | Racket |
#lang at-exp racket
(require ffi/unsafe)
(define mouse-event
(get-ffi-obj "mouse_event" (ffi-lib "user32")
(_fun _int32 _int32 _int32 _int32 _pointer -> _void)))
(mouse-event #x2 0 0 0 #f)
(mouse-event #x4 0 0 0 #f)
| |
http://rosettacode.org/wiki/Singly-linked_list/Element_definition | Singly-linked list/Element definition | singly-linked list
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked list: Element definition, Element insertion, Lis... | #ALGOL_W | ALGOL W | % record type to hold a singly linked list of integers %
record ListI ( integer iValue; reference(ListI) next );
% declare a variable to hold a list %
reference(ListI) head;
% create a list of integers ... |
http://rosettacode.org/wiki/Singly-linked_list/Element_definition | Singly-linked list/Element definition | singly-linked list
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked list: Element definition, Element insertion, Lis... | #ARM_Assembly | ARM Assembly |
/* ARM assembly Raspberry PI */
/* program defList.s */
/* Constantes */
.equ STDOUT, 1 @ Linux output console
.equ EXIT, 1 @ Linux syscall
.equ READ, 3
.equ WRITE, 4
.equ NBELEMENTS, 100 @ list size
/***************************... |
http://rosettacode.org/wiki/Singly-linked_list/Traversal | Singly-linked list/Traversal | Traverse from the beginning of a singly-linked list to the end.
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked ... | #AArch64_Assembly | AArch64 Assembly |
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program afficheList64.s */
/*******************************************/
/* Constantes file */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantes... |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #Scratch | Scratch | const proc: bubbleSort (inout array elemType: arr) is func
local
var boolean: swapped is FALSE;
var integer: i is 0;
var elemType: help is elemType.value;
begin
repeat
swapped := FALSE;
for i range 1 to length(arr) - 1 do
if arr[i] > arr[i + 1] then
help := arr[i];
... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Sidef | Sidef | class Singleton(name) {
static instance;
method new(name) {
instance := Singleton.bless(Hash(:name => name));
}
method new {
Singleton.new(nil);
}
}
var s1 = Singleton('foo');
say s1.name; #=> 'foo'
say s1.object_id; #=> '30424504'
var s2 = Singleton();... |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #PureBasic | PureBasic | If AW_WinActivate("Calc")
AW_SendKeys("123+3=")
EndIf |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #Python | Python | import autopy
autopy.key.type_string("Hello, world!") # Prints out "Hello, world!" as quickly as OS will allow.
autopy.key.type_string("Hello, world!", wpm=60) # Prints out "Hello, world!" at 60 WPM.
autopy.key.tap(autopy.key.Code.RETURN)
autopy.key.tap(autopy.key.Code.F1)
autopy.key.tap(autopy.key.Code.LEFT_ARROW) |
http://rosettacode.org/wiki/Simple_turtle_graphics | Simple turtle graphics | The first turtle graphic discussed in Mindstorms: Children, Computers, and Powerful Ideas by Seymour Papert is a simple drawing of a house. It is a square with a triangle on top for the roof.
For a slightly more advanced audience, a more practical introduction to turtle graphics might be to draw a bar chart.
See imag... | #Perl | Perl | #!/usr/bin/perl
use strict; # https://rosettacode.org/wiki/Simple_turtle_graphics
use warnings;
use Tk;
use List::Util qw( max );
my $c; # the canvas
# turtle routines
my $pen = 1; # true for pendown, false for penup
my @location = (0, 0); # upper left corner
my $direction = 0; # 0 for East, increasing clockwi... |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #Raku | Raku | use X11::libxdo;
my $xdo = Xdo.new;
my ($dw, $dh) = $xdo.get-desktop-dimensions( 0 );
sleep .25;
for ^$dw -> $mx {
my $my = (($mx / $dh * τ).sin * 500).abs.Int + 200;
$xdo.move-mouse( $mx, $my, 0 );
my ($x, $y, $window-id, $screen) = $xdo.get-mouse-info;
my $name = (try $xdo.get-window-name($windo... | |
http://rosettacode.org/wiki/Singly-linked_list/Element_definition | Singly-linked list/Element definition | singly-linked list
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked list: Element definition, Element insertion, Lis... | #ATS | ATS | (* The Rosetta Code linear list type can contain any vt@ype.
(The ‘@’ means it doesn’t have to be the size of a pointer.
You can read {0 <= n} as ‘for all non-negative n’. *)
dataviewtype rclist_vt (vt : vt@ype+, n : int) =
| rclist_vt_nil (vt, 0)
| {0 <= n} rclist_vt_cons (vt, n + 1) of (vt, rclist_vt (vt, n))
... |
http://rosettacode.org/wiki/Singly-linked_list/Element_definition | Singly-linked list/Element definition | singly-linked list
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked list: Element definition, Element insertion, Lis... | #AutoHotkey | AutoHotkey | element = 5 ; data
element_next = element2 ; link to next element |
http://rosettacode.org/wiki/Singly-linked_list/Traversal | Singly-linked list/Traversal | Traverse from the beginning of a singly-linked list to the end.
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked ... | #ACL2 | ACL2 | (defun traverse (xs)
(if (endp xs)
(cw "End.~%")
(prog2$ (cw "~x0~%" (first xs))
(traverse (rest xs))))) |
http://rosettacode.org/wiki/Singly-linked_list/Traversal | Singly-linked list/Traversal | Traverse from the beginning of a singly-linked list to the end.
See also
Array
Associative array: Creation, Iteration
Collections
Compound data type
Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
Linked list
Queue: Definition, Usage
Set
Singly-linked ... | #Action.21 | Action! | SET EndProg=* |
http://rosettacode.org/wiki/Sleep | Sleep | Task
Write a program that does the following in this order:
Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description.
Print "Sleeping..."
Sleep the main thread for the given amount of time.
... | #11l | 11l | V seconds = Float(input())
print(‘Sleeping...’)
sleep(seconds)
print(‘Awake!’) |
http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort | Sorting algorithms/Bubble sort |
Sorting Algorithm
This is a sorting algorithm. It may be applied to a set of data in order to sort it.
For comparing various sorts, see compare sorts.
For other sorting algorithms, see sorting algorithms, or:
O(n logn) sorts
Heap sort |
Merge sort |
Patience sort |
Quick sort
O(n log2n) sorts
Shell Sort
... | #Seed7 | Seed7 | const proc: bubbleSort (inout array elemType: arr) is func
local
var boolean: swapped is FALSE;
var integer: i is 0;
var elemType: help is elemType.value;
begin
repeat
swapped := FALSE;
for i range 1 to length(arr) - 1 do
if arr[i] > arr[i + 1] then
help := arr[i];
... |
http://rosettacode.org/wiki/Singleton | Singleton | A Global Singleton is a class of which only one instance exists within a program.
Any attempt to use non-static members of the class involves performing operations on this one instance.
| #Slate | Slate | define: #Singleton &builder: [Oddball clone] |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #Racket | Racket | #lang racket/gui
(define frame (new frame%
(label "Example")
(width 300)
(height 300))) ; Defines an instance of a frame to put the canvas in
(define simulate-key-canvas%
(class canvas%
(define/public (simulate-key key)
(send this on-cha... |
http://rosettacode.org/wiki/Simulate_input/Keyboard | Simulate input/Keyboard | Task
Send simulated keystrokes to a GUI window, or terminal.
You should specify whether the target may be externally created
(i.e., if the keystrokes are going to an application
other than the application that is creating them).
| #Raku | Raku | use X11::libxdo;
my $xdo = Xdo.new;
my $active = $xdo.get-active-window;
my $command = $*VM.config<os> eq 'darwin' ?? 'open' !! 'xdg-open';
shell "$command https://www.google.com";
sleep 1;
my $match = rx[^'Google '];
say my $w = $xdo.search(:name($match))<ID>;
sleep .25;
if $w {
$xdo.activate-win... |
http://rosettacode.org/wiki/Simple_turtle_graphics | Simple turtle graphics | The first turtle graphic discussed in Mindstorms: Children, Computers, and Powerful Ideas by Seymour Papert is a simple drawing of a house. It is a square with a triangle on top for the roof.
For a slightly more advanced audience, a more practical introduction to turtle graphics might be to draw a bar chart.
See imag... | #Phix | Phix | -- demo\rosetta\turtle.e
include pGUI.e
global Ihandle canvas, dlg
global cdCanvas cdcanvas
global bool pen_down = false
global procedure pendown(atom colour=CD_BLACK)
pen_down = true
cdCanvasSetForeground(cdcanvas, colour)
end procedure
global procedure penup()
pen_down = false
end procedure
|
http://rosettacode.org/wiki/Simple_turtle_graphics | Simple turtle graphics | The first turtle graphic discussed in Mindstorms: Children, Computers, and Powerful Ideas by Seymour Papert is a simple drawing of a house. It is a square with a triangle on top for the roof.
For a slightly more advanced audience, a more practical introduction to turtle graphics might be to draw a bar chart.
See imag... | #Python | Python | from turtle import *
def rectangle(width, height):
for _ in range(2):
forward(height)
left(90)
forward(width)
left(90)
def square(size):
rectangle(size, size)
def triangle(size):
for _ in range(3):
forward(size)
right(120)
def house(size):
right(18... |
http://rosettacode.org/wiki/Simulate_input/Mouse | Simulate input/Mouse | #Ring | Ring |
# Project : Simulate input/Mouse
load "guilib.ring"
load "stdlib.ring"
paint = null
new qapp
{
win1 = new qwidget() {
setwindowtitle("")
setgeometry(100,100,800,600)
setwindowtitle("Mouse events")
line1 = new qlineedit(wi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.