Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

3
Task/Sleep/00-META.yaml Normal file
View file

@ -0,0 +1,3 @@
---
from: http://rosettacode.org/wiki/Sleep
note: Basic language learning

13
Task/Sleep/00-TASK.txt Normal file
View file

@ -0,0 +1,13 @@
;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.
* [[Hello world/Text|Print]] "Sleeping..."
* Sleep the main [[thread]] for the given amount of time.
* Print "Awake!"
* End.
<br>
;Related task:
* &nbsp; [[Nautical bell]]
<br><br>

4
Task/Sleep/11l/sleep.11l Normal file
View file

@ -0,0 +1,4 @@
V seconds = Float(input())
print(Sleeping...)
sleep(seconds)
print(Awake!)

View file

@ -0,0 +1,106 @@
START
PRINT DATA,GEN
YREGS , REGISTER EQUATES (e.g. 0 = R0)
SLEEP CSECT
SLEEP AMODE 31 addressing mode 31 bit
SLEEP RMODE ANY loader determines 31 or 24
***********************************************************************
* REENTRANT. Logically swap out a task for a number of seconds
* specified in PARM. Minimum 0, maximum 60 seconds
*
* MVS rexx (the original rexx) does not have a sleep function. This
* program can be called from rexx, assuming this program is in
* LINKLIST, as follows:
*
* /* rexx */
* wait_time = '6' /* number of seconds to sleep */
* say 'Sleeping...'
* address LINKMVS "SLEEP wait_time" /* invoke SLEEP */
* say 'Awake!
***********************************************************************
PROLOG BAKR R14,0 satck caller's registers
LR R4,R1 save parm pointer
LR R12,R15 entry point addr to R12
USING SLEEP,R12 tell assembler about that
B AROUND avoid abend S0C1
DC C'SLEEP ' CSECT NAME
DC C'C=2014.05.10 ' CHANGE DATE
DC C'A=&SYSDATE ' ASSEMBLY DATE
DC C'T=&SYSTIME ' CHANGE TIME
DC C'MarcvdM. ' PROGRAMMER NAME
AROUND L R10,0(0,R4) load parm address in R10
XR R15,R15 clear R15
LH R15,0(0,R10) load parm length in R15
LR R6,R15 save length in R6
LTR R15,R15 parm length 0?
BZ NOPARM yes, exit before getmain
C R6,F2 parmlength > 2 ?
BH NOPARM yes, exit before getmain
STORAGE OBTAIN,LENGTH=WALEN,LOC=ANY get some storage
LR R9,R1 address of storage in R9
USING WAREAX,R9 base for data section (DSECT)
MVC EYECAT,=C'**MARC**' make storage easy to find in dump
MVC SECONDS,C00 set field to F0F0
C R6,F1 parmlength = 1?
BNE COPYSECS no, copy both bytes
MVC SECONDS+1(1),2(R10) yes, just copy one byte.
B TRTEST
COPYSECS MVC SECONDS,2(R10)
* test supplied parameter for valid integer values
TRTEST TRT SECONDS(1),VALINT6 first parm byte no higher as 6?
BNZ NOPARM_REL higher, release storage and return
TRT SECONDS+1(1),VALINT9 second byte valid?
BNZ NOPARM_REL no, release storage and return
CLC SECONDS(1),=C'6' first parm byte < 6?
BNE DOWAIT yes, do wait
CLC SECONDS+1(1),=C'0' first eq. 6, second > 0?
BNE NOPARM_REL yes, release storage and return
DOWAIT DS 0H
MVC WAWTO(DWTOL),DWTO copy WTO list form to obtained st.
MVC WAWTO+18(2),SECONDS copy in nr. of seconds
WTO MF=(E,WAWTO) issue WTO, execute form
MVC HOURS,C00 zero out hours
MVC MINUTS,C00 and minutes
MVC REST,C00 and milliseconds
STIMER WAIT,DINTVL=TIMEVAL SVC 47: logical swap out (sleep)
B EXIT done
NOPARM_REL DS 0H
STORAGE RELEASE,ADDR=(R9),LENGTH=WALEN free obtained storage
LA R15,4 set return code 4
B RETURN return to caller
EXIT DS 0H
STORAGE RELEASE,ADDR=(R9),LENGTH=WALEN free obtained storage
WTO ' Awake!',ROUTCDE=11 fixed wake-up string
NOPARM EQU *
RETURN PR , return to caller
*
* --------------------------------------------------------------------
* CONSTANTS
* --------------------------------------------------------------------
DWTO WTO ' Sleeping... (XX seconds)',ROUTCDE=11,MF=L
DWTOL EQU *-DWTO length of WTO list form
F1 DC F'1'
F2 DC F'2'
C00 DC C'00'
VALINT6 DC 256XL1'01'
ORG *-16
VALOK6 DC 7XL1'00' F0-F6: OFFSETS 240-246
VALINT9 DC 256XL1'01'
ORG *-16
VALOK9 DC 10XL1'00' F0-F9: OFFSETS 240-249
DS 0D
LTORG , FORCE DISPLACEMENT LITERALS
* --------------------------------------------------------------------
* DSECT (data section)
* --------------------------------------------------------------------
WAREAX DSECT ,
WAWTO DS CL(DWTOL) reentrant WTO area
EYECAT DS CL8
TIMEVAL DS 0CL8
HOURS DS CL2 will be zeroed
MINUTS DS CL2 will be zeroed
SECONDS DS CL2 from parm
REST DS CL2 will be zeroed
WALEN EQU *-WAREAX length of DSECT
* --------------------------------------------------------------------
END SLEEP

View file

@ -0,0 +1,23 @@
ORG RESET
jmp main
ORG TIMER0
; timer interrupt only used to wake the processor
clr tr0
reti
main:
setb ea ; enable interrupts
setb et0 ; enable timer0 interrupt
mov tl0, #0 ; start timer counter at zero
mov th0, #0 ; these two values dictate the length of sleep
mov a, pcon ; copy power control register
setb a.0 ; set idl bit
setb tr0 ; start timer
; sleeping...
mov pcon, a ; move a back into pcon (processor sleeps after this instruction finishes)
; when the timer overflows and the timer interrupt returns, execution will resume at this spot
; Awake!
jmp $

4
Task/Sleep/8th/sleep.8th Normal file
View file

@ -0,0 +1,4 @@
f:stdin f:getline
"Sleeping..." . cr
eval sleep
"Awake!" . cr bye

View file

@ -0,0 +1,88 @@
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program sleep64.s */
/*******************************************/
/* Constantes file */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeConstantesARM64.inc"
.equ SLEEP, 0x65 // Linux syscall
.equ BUFFERSIZE, 100
/*******************************************/
/* Initialized data */
/*******************************************/
.data
szMessQuest: .asciz "Enter the time to sleep in seconds : "
szMessError: .asciz "Error occured.\n"
szMessSleep: .asciz "Sleeping Zzzzzzz.\n"
szMessAwake: .asciz "Awake!!!\n"
szCarriageReturn: .asciz "\n"
/*******************************************/
/* UnInitialized data */
/*******************************************/
.bss
.align 4
ZonesAttente:
qSecondes: .skip 8
qMicroSecondes: .skip 8
ZonesTemps: .skip 16
sBuffer: .skip BUFFERSIZE
/*******************************************/
/* code section */
/*******************************************/
.text
.global main
main:
ldr x0,qAdrszMessQuest // display invite message
bl affichageMess
mov x0,STDIN // input standard linux
ldr x1,qAdrsBuffer
mov x2,BUFFERSIZE
mov x8,READ // read input string
svc 0
cmp x0,0 // read error ?
ble 99f
//
ldr x0,qAdrsBuffer // buffer address
bl conversionAtoD // conversion string in number in x0
ldr x1,qAdrqSecondes
str x0,[x1] // store second number in area
ldr x0,qAdrszMessSleep // display sleeping message
bl affichageMess
ldr x0,qAdrZonesAttente // delay area
ldr x1,qAdrZonesTemps //
mov x8,#SLEEP // call system SLEEP
svc 0
cmp x0,#0 // error sleep ?
blt 99f
ldr x0,qAdrszMessAwake // display awake message
bl affichageMess
mov x0, #0 // return code
b 100f
99: // display error message
ldr x0,qAdrszMessError
bl affichageMess
mov x0, 1 // return code
100: // standard end of the program
mov x8,EXIT // request to exit program
svc 0 // perform system call
qAdrszMessQuest: .quad szMessQuest
qAdrszMessError: .quad szMessError
qAdrszMessSleep: .quad szMessSleep
qAdrszMessAwake: .quad szMessAwake
qAdrqSecondes: .quad qSecondes
qAdrZonesAttente: .quad ZonesAttente
qAdrZonesTemps: .quad ZonesTemps
qAdrsBuffer: .quad sBuffer
qAdrszCarriageReturn: .quad szCarriageReturn
/********************************************************/
/* File Include fonctions */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"

View file

@ -0,0 +1,8 @@
# using ping to sleep #
INT milliseconds = read int; # ping uses milliseconds #
print ("Sleeping...");
VOID (system ("ping 0.0.0.1 -n 1 -w " + whole (milliseconds, 0) + " >NUL"));
# 0.0.0.1 is an invalid IP address and cannot be used, so this will never conflict with a real IP address #
# ping -n gives number of tries, -w timeout, and >NUL deletes output so the user does not see it #
print (new line);
print ("Awake!")

4
Task/Sleep/ANT/sleep.ant Normal file
View file

@ -0,0 +1,4 @@
milliseconds: eval[input["How long should I sleep? "]] / eval = evil, but this is just a simple demo
echo["Sleeping..."]
sleep[milliseconds]
echo["Awake!"]

View file

@ -0,0 +1,163 @@
/* ARM assembly Raspberry PI */
/* program sleepAsm.s */
/* Constantes */
.equ STDIN, 0 @ Linux input console
.equ STDOUT, 1 @ Linux output console
.equ EXIT, 1 @ Linux syscall
.equ READ, 3 @ Linux syscall
.equ WRITE, 4 @ Linux syscall
.equ SLEEP, 0xa2 @ Linux syscall
.equ BUFFERSIZE, 100
/* Initialized data */
.data
szMessQuest: .asciz "Enter the time to sleep in seconds : "
szMessError: .asciz "Error occured.\n"
szMessSleep: .asciz "Sleeping Zzzzzzz.\n"
szMessAwake: .asciz "Awake!!!\n"
szCarriageReturn: .asciz "\n"
/* UnInitialized data */
.bss
.align 4
ZonesAttente:
iSecondes: .skip 4
iMicroSecondes: .skip 4
ZonesTemps: .skip 8
sBuffer: .skip BUFFERSIZE
/* code section */
.text
.global main
main:
ldr r0,iAdrszMessQuest @ display invite message
bl affichageMess
mov r0,#STDIN @ input standard linux
ldr r1,iAdrsBuffer
mov r2,#BUFFERSIZE
mov r7,#READ @ read input string
svc 0
cmp r0,#0 @ read error ?
ble 99f
@
ldr r0,iAdrsBuffer @ buffer address
bl conversionAtoD @ conversion string in number in r0
ldr r1,iAdriSecondes
str r0,[r1] @ store second number in area
ldr r0,iAdrszMessSleep @ display sleeping message
bl affichageMess
ldr r0,iAdrZonesAttente @ delay area
ldr r1,iAdrZonesTemps @
mov r7,#SLEEP @ call system SLEEP
svc 0
cmp r0,#0 @ error sleep ?
blt 99f
ldr r0,iAdrszMessAwake @ display awake message
bl affichageMess
mov r0, #0 @ return code
b 100f
99: @ display error message
ldr r0,iAdrszMessError
bl affichageMess
mov r0, #1 @ return code
100: @ standard end of the program
mov r7, #EXIT @ request to exit program
svc 0 @ perform system call
iAdrszMessQuest: .int szMessQuest
iAdrszMessError: .int szMessError
iAdrszMessSleep: .int szMessSleep
iAdrszMessAwake: .int szMessAwake
iAdriSecondes: .int iSecondes
iAdrZonesAttente: .int ZonesAttente
iAdrZonesTemps: .int ZonesTemps
iAdrsBuffer: .int sBuffer
iAdrszCarriageReturn: .int szCarriageReturn
/******************************************************************/
/* display text with size calculation */
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
push {r0,r1,r2,r7,lr} @ save registers
mov r2,#0 @ counter length */
1: @ loop length calculation
ldrb r1,[r0,r2] @ read octet start position + index
cmp r1,#0 @ if 0 its over
addne r2,r2,#1 @ else add 1 in the length
bne 1b @ and loop
@ so here r2 contains the length of the message
mov r1,r0 @ address message in r1
mov r0,#STDOUT @ code to write to the standard output Linux
mov r7, #WRITE @ code call system "write"
svc #0 @ call system
pop {r0,r1,r2,r7,lr} @ restaur registers
bx lr @ return
/******************************************************************/
/* Convert a string to a number stored in a registry */
/******************************************************************/
/* r0 contains the address of the area terminated by 0 or 0A */
/* r0 returns a number */
conversionAtoD:
push {fp,lr} @ save 2 registers
push {r1-r7} @ save others registers
mov r1,#0
mov r2,#10 @ factor
mov r3,#0 @ counter
mov r4,r0 @ save address string -> r4
mov r6,#0 @ positive sign by default
mov r0,#0 @ initialization to 0
1: /* early space elimination loop */
ldrb r5,[r4,r3] @ loading in r5 of the byte located at the beginning + the position
cmp r5,#0 @ end of string -> end routine
beq 100f
cmp r5,#0x0A @ end of string -> end routine
beq 100f
cmp r5,#' ' @ space ?
addeq r3,r3,#1 @ yes we loop by moving one byte
beq 1b
cmp r5,#'-' @ first character is -
moveq r6,#1 @ 1 -> r6
beq 3f @ then move on to the next position
2: /* beginning of digit processing loop */
cmp r5,#'0' @ character is not a number
blt 3f
cmp r5,#'9' @ character is not a number
bgt 3f
/* character is a number */
sub r5,#48
ldr r1,iMaxi @ check the overflow of the register
cmp r0,r1
bgt 99f @ overflow error
mul r0,r2,r0 @ multiply par factor 10
add r0,r5 @ add to r0
3:
add r3,r3,#1 @ advance to the next position
ldrb r5,[r4,r3] @ load byte
cmp r5,#0 @ end of string -> end routine
beq 4f
cmp r5,#0x0A @ end of string -> end routine
beq 4f
b 2b @ loop
4:
cmp r6,#1 @ test r6 for sign
moveq r1,#-1
muleq r0,r1,r0 @ if negatif, multiply par -1
b 100f
99: /* overflow error */
ldr r0,=szMessErrDep
bl affichageMess
mov r0,#0 @ return zero if error
100:
pop {r1-r7} @ restaur other registers
pop {fp,lr} @ restaur 2 registers
bx lr @return procedure
/* constante program */
iMaxi: .int 1073741824
szMessErrDep: .asciz "Too large: overflow 32 bits.\n"
.align 4

12
Task/Sleep/AWK/sleep.awk Normal file
View file

@ -0,0 +1,12 @@
# syntax: GAWK -f SLEEP.AWK [seconds]
BEGIN {
print("Sleeping...")
loop(ARGV[1])
print("Awake!")
exit(0)
}
function loop(seconds, t) {
# awk lacks a sleep mechanism, so simulate one by looping
t = systime()
while (systime() < t + seconds) {}
}

View file

@ -0,0 +1,70 @@
BYTE RTCLOK1=$13
BYTE RTCLOK2=$14
BYTE PALNTSC=$D014
PROC Wait(CARD frames)
BYTE lsb=frames,msb=frames+1
;wait lsb of frames
lsb==+RTCLOK2
WHILE lsb#RTCLOK2 DO OD
;wait msb of 256*frames
WHILE msb>0
DO
WHILE lsb=RTCLOK2 DO OD
WHILE lsb#RTCLOK2 DO OD
msb==-1
OD
RETURN
CARD FUNC GetFrame()
CARD res
BYTE lsb=res,msb=res+1
lsb=RTCLOK2
msb=RTCLOK1
RETURN (res)
CARD FUNC MsToFrames(CARD ms)
CARD res
IF PALNTSC=15 THEN
res=ms/60
ELSE
res=ms/50
FI
RETURN (res)
CARD FUNC FramesToMs(CARD frames)
CARD res
IF PALNTSC=15 THEN
res=frames*60
ELSE
res=frames*50
FI
RETURN (res)
PROC Main()
CARD ARRAY data=[1 5 10 50 100 500]
CARD beg,end,diff,diffMs,delay,delayMs
BYTE i
FOR i=0 TO 5
DO
delay=data(i)
delayMs=FramesToMs(delay)
PrintF("Wait %U frames / %U ms...%E",delay,delayMs)
beg=GetFrame()
Wait(delay)
end=GetFrame()
diff=end-beg
diffMs=FramesToMs(diff)
PrintF("Frame number at begin %U%E",beg)
PrintF("Frame number at end %U%E",end)
PrintF("Waited %U-%U=%U frames / %U ms%E%E",end,beg,diff,diffMs)
OD
RETURN

11
Task/Sleep/Ada/sleep.ada Normal file
View file

@ -0,0 +1,11 @@
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Float_Text_Io; use Ada.Float_Text_Io;
procedure Sleep is
In_Val : Float;
begin
Get(In_Val);
Put_Line("Sleeping...");
delay Duration(In_Val);
Put_Line("Awake!");
end Sleep;

View file

@ -0,0 +1,9 @@
o_text("Sleeping...\n");
# Sleep X seconds
sleep(atoi(argv(1)));
# Sleep X microseconds
#usleep(atoi(argv(1)));
o_text("Awake!\n");

View file

@ -0,0 +1,9 @@
10 POKE 768,169: POKE 770,76
20 POKE 771,168: POKE 772,252
30 INPUT "ENTER WAIT VALUE (1-256) : ";A
40 IF A < 1 OR A > 256 THEN 30
50 POKE 769,(A < 256) * A
60 LET C = (26 + 27 * A + 5 * A ^ 2) / 2
70 PRINT "WAIT FOR "C" CYCLES OR "
80 PRINT C * 14 / 14.318181" MICROSECONDS"
90 PRINT "SLEEPING": CALL 768: PRINT "AWAKE"

View file

@ -0,0 +1,4 @@
time: to :integer input "Enter number of milliseconds: "
print "Sleeping..."
pause time
print "Awake!"

View file

@ -0,0 +1,4 @@
TrayTip, sleeping, sleeping
sleep, 2000 ; 2 seconds
TrayTip, awake, awake
Msgbox, awake

View file

@ -0,0 +1,6 @@
#AutoIt Version: 3.2.10.0
$sleep_me=InputBox("Sleep", "Number of seconds to sleep", "10", "", -1, -1, 0, 0)
Dim $sleep_millisec=$sleep_me*1000
MsgBox(0,"Sleep","Sleeping for "&$sleep_me&" sec")
sleep ($sleep_millisec)
MsgBox(0,"Awake","... Awaking")

15
Task/Sleep/Axe/sleep.axe Normal file
View file

@ -0,0 +1,15 @@
Disp "TIME:"
input→A
0→T
length(A)→L
For(I,1,L)
If {A}<'0' or {A}>'9'
Disp "NOT A NUMBER",i
Return
End
T*10+{A}-'0'→T
A++
End
Disp "SLEEPING...",i
Pause T
Disp "AWAKE",i

View file

@ -0,0 +1,4 @@
INPUT sec 'the SLEEP command takes seconds
PRINT "Sleeping..."
SLEEP sec
PRINT "Awake!"

View file

@ -0,0 +1,6 @@
print "Enter number of seconds to sleep: ";
input ms
print "Sleeping..."
pause ms
print "Awake!"
end

View file

@ -0,0 +1,4 @@
INPUT "Enter the time to sleep in centiseconds: " sleep%
PRINT "Sleeping..."
WAIT sleep%
PRINT "Awake!"

View file

@ -0,0 +1,6 @@
'---The SLEEP command takes milliseconds by default but we will adjust it
PRINT "Enter a number for each second you want to wait\nthen press Enter "
INPUT millisec
PRINT "Sleeping..."
SLEEP millisec * 1000
PRINT "Awake!"

View file

@ -0,0 +1,6 @@
@echo off
set /p Seconds=Enter the number of seconds to sleep:
set /a Seconds+=1
echo Sleeping ...
ping -n %Seconds% localhost >nul 2>&1
echo Awake!

View file

@ -0,0 +1,5 @@
@echo off
set /p MilliSeconds=Enter the number of milliseconds to sleep:
echo Sleeping ...
ping -n 1 -w %MilliSeconds% 1.2.3.4 >nul 2>&1
echo Awake!

View file

@ -0,0 +1,5 @@
@echo off
set /p Seconds=Enter the number of seconds to sleep:
echo Sleeping ...
timeout /t %Seconds% /nobreak >nul
echo Awake!

View file

@ -0,0 +1,11 @@
#include <iostream>
#include <thread>
#include <chrono>
int main()
{
unsigned long microseconds;
std::cin >> microseconds;
std::cout << "Sleeping..." << std::endl;
std::this_thread::sleep_for(std::chrono::microseconds(microseconds));
std::cout << "Awake!\n";
}

View file

@ -0,0 +1,14 @@
#include <unistd.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
useconds_t microseconds;
cin >> microseconds;
cout << "Sleeping..." << endl;
usleep(microseconds);
cout << "Awake!" << endl;
return 0;
}

View file

@ -0,0 +1,13 @@
using System;
using System.Threading;
class Program
{
static void Main(string[] args)
{
int sleep = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Sleeping...");
Thread.Sleep(sleep); //milliseconds
Console.WriteLine("Awake!");
}
}

12
Task/Sleep/C/sleep.c Normal file
View file

@ -0,0 +1,12 @@
#include <stdio.h>
#include <unistd.h>
int main()
{
unsigned int seconds;
scanf("%u", &seconds);
printf("Sleeping...\n");
sleep(seconds);
printf("Awake!\n");
return 0;
}

View file

@ -0,0 +1,18 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Sleep-In-Seconds.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Seconds-To-Sleep USAGE COMP-2.
PROCEDURE DIVISION.
ACCEPT Seconds-To-Sleep
DISPLAY "Sleeping..."
CALL "C$SLEEP" USING BY CONTENT Seconds-To-Sleep
DISPLAY "Awake!"
GOBACK
.

View file

@ -0,0 +1,23 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Sleep-In-Nanoseconds.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Seconds-To-Sleep USAGE COMP-2.
01 Nanoseconds-To-Sleep USAGE COMP-2.
01 Nanoseconds-Per-Second CONSTANT 1000000000.
PROCEDURE DIVISION.
ACCEPT Seconds-To-Sleep
MULTIPLY Seconds-To-Sleep BY Nanoseconds-Per-Second
GIVING Nanoseconds-To-Sleep
DISPLAY "Sleeping..."
CALL "CBL_OC_NANOSLEEP"
USING BY CONTENT Nanoseconds-To-Sleep
DISPLAY "Awake!"
GOBACK
.

View file

@ -0,0 +1,6 @@
(defn sleep [ms] ; time in milliseconds
(println "Sleeping...")
(Thread/sleep ms)
(println "Awake!"))
; call it
(sleep 1000)

View file

@ -0,0 +1,7 @@
(defun test-sleep ()
(let ((seconds (read)))
(format t "Sleeping...~%")
(sleep seconds)
(format t "Awake!~%")))
(test-sleep)

12
Task/Sleep/D/sleep.d Normal file
View file

@ -0,0 +1,12 @@
import std.stdio, core.thread;
void main() {
write("Enter a time to sleep (in seconds): ");
long secs;
readf(" %d", &secs);
writeln("Sleeping...");
Thread.sleep(dur!"seconds"(secs));
writeln("Awake!");
}

11
Task/Sleep/DBL/sleep.dbl Normal file
View file

@ -0,0 +1,11 @@
;
; Sleep for DBL version 4 by Dario B.
;
PROC
;------------------------------------------------------------------
XCALL FLAGS (0007000000,1) ;Suppress STOP message
OPEN(1,O,'TT:')
DISPLAY (1,"Sleeping...",10)
SLEEP 10 ;Sleep for 10 seconds
DISPLAY (1,"Awake!",10)

4
Task/Sleep/DCL/sleep.dcl Normal file
View file

@ -0,0 +1,4 @@
$ amount_of_time = p1 ! hour[:[minute][:[second][.[hundredth]]]]
$ write sys$output "Sleeping..."
$ wait 'amount_of_time
$ write sys$output "Awake!"

View file

@ -0,0 +1,17 @@
START ;Demonstrate the SLEEP function
RECORD SLEEPING
, A8, "Sleeping"
RECORD WAKING
, A6,"Awake"
PROC
XCALL FLAGS (0007000000,1) ;Suppress STOP message
OPEN(8,O,'TT:')
WRITES(8,SLEEPING)
SLEEP 30 ; Sleep for 30 seconds
WRITES(8,WAKING)
END

View file

@ -0,0 +1,17 @@
program SleepOneSecond;
{$APPTYPE CONSOLE}
uses SysUtils;
var
lTimeToSleep: Integer;
begin
if ParamCount = 0 then
lTimeToSleep := 1000
else
lTimeToSleep := StrToInt(ParamStr(1));
WriteLn('Sleeping...');
Sleep(lTimeToSleep); // milliseconds
WriteLn('Awake!');
end.

View file

@ -0,0 +1,10 @@
begin_instuct(sleepTime);
ask_human()_first()_msg(Enter number of seconds to sleep: )_var(sleepSecs)_me();
set_decision(asynchronous)_me();
me_msg(Sleeping...);
me_sleep[sleepSecs]_unit(secs);
me_msg(Awake!);
reset_decision()_me();
end_instruct(sleepTime);
exec_instruct(sleepTime)_me();

7
Task/Sleep/E/sleep.e Normal file
View file

@ -0,0 +1,7 @@
def sleep(milliseconds :int, nextThing) {
stdout.println("Sleeping...")
timer.whenPast(timer.now() + milliseconds, fn {
stdout.println("Awake!")
nextThing()
})
}

11
Task/Sleep/EGL/sleep.egl Normal file
View file

@ -0,0 +1,11 @@
program Sleep type BasicProgram{}
// Syntax: sysLib.wait(time BIN(9,2) in)
function main()
SysLib.writeStdout("Sleeping!");
sysLib.wait(15); // waits for 15 seconds
SysLib.writeStdout("Awake!");
end
end

View file

@ -0,0 +1,13 @@
^|The pause command takes milliseconds, we adjust to seconds|^
fun main = int by List args
int seconds
if args.length == 1 do seconds = int!args[0] end
if seconds == 0
seconds = ask(int, "Enter number of seconds to sleep: ")
end
writeLine("Sleeping...")
pause(1000 * seconds)
writeLine("Awake!")
return 0
end
exit main(Runtime.args)

View file

@ -0,0 +1,6 @@
..............
INPUT("Enter the time to sleep in seconds: ";sleep)
PRINT("Sleeping...")
PAUSE(sleep)
PRINT("Awake!")
..............

17
Task/Sleep/Eiffel/sleep.e Normal file
View file

@ -0,0 +1,17 @@
class
APPLICATION
inherit
EXECUTION_ENVIRONMENT
create
make
feature -- Initialization
make
-- Sleep for a given number of nanoseconds.
do
print ("Enter a number of nanoseconds: ")
io.read_integer_64
print ("Sleeping...%N")
sleep (io.last_integer_64)
print ("Awake!%N")
end
end

View file

@ -0,0 +1,9 @@
import extensions;
public program()
{
int sleep := console.readLine().toInt();
console.printLine("Sleeping...");
system'threading'threadControl.sleep(sleep);
console.printLine("Awake!")
}

View file

@ -0,0 +1,8 @@
sleep = fn seconds ->
IO.puts "Sleeping..."
:timer.sleep(1000 * seconds) # in milliseconds
IO.puts "Awake!"
end
sec = if System.argv==[], do: 1, else: hd(System.argv) |> String.to_integer
sleep.(sec)

View file

@ -0,0 +1,4 @@
(let ((seconds (read-number "Time in seconds: ")))
(message "Sleeping ...")
(sleep-for seconds)
(message "Awake!"))

View file

@ -0,0 +1,4 @@
main() ->
io:format("Sleeping...~n"),
timer:sleep(1000), %% in milliseconds
io:format("Awake!~n").

View file

@ -0,0 +1,6 @@
main() ->
io:format("Sleeping...~n"),
receive
after 1000 -> ok %% in milliseconds
end,
io:format("Awake!~n").

View file

@ -0,0 +1,10 @@
open System
open System.Threading
[<EntryPoint>]
let main args =
let sleep = Convert.ToInt32(Console.ReadLine())
Console.WriteLine("Sleeping...")
Thread.Sleep(sleep); //milliseconds
Console.WriteLine("Awake!")
0

View file

@ -0,0 +1,8 @@
#APPTYPE CONSOLE
DIM %msec
PRINT "Milliseconds to sleep: ";
%msec = FILEGETS(stdin, 10)
PRINT "Sleeping..."
SLEEP(%msec)
PRINT "Awake!"
PAUSE

View file

@ -0,0 +1,7 @@
USING: calendar io math.parser threads ;
: read-sleep ( -- )
readln string>number seconds
"Sleeping..." print
sleep
"Awake!" print ;

View file

@ -0,0 +1,21 @@
using concurrent
class Main
{
public static Void main ()
{
echo ("Enter a time to sleep: ")
input := Env.cur.in.readLine
try
{
time := Duration.fromStr (input)
echo ("sleeping ...")
Actor.sleep (time)
echo ("awake!")
}
catch
{
echo ("Invalid time entered")
}
}
}

View file

@ -0,0 +1,4 @@
: sleep ( ms -- )
." Sleeping..."
ms
." awake." cr ;

View file

@ -0,0 +1,18 @@
program test_sleep
implicit none
integer :: iostat
integer :: seconds
character (32) :: argument
if (iargc () == 1) then
call getarg (1, argument)
read (argument, *, iostat = iostat) seconds
if (iostat == 0) then
write (*, '(a)') 'Sleeping...'
call sleep (seconds)
write (*, '(a)') 'Awake!'
end if
end if
end program test_sleep

View file

@ -0,0 +1,8 @@
' FB 1.05.0 Win64
Dim ms As UInteger
Input "Enter number of milliseconds to sleep" ; ms
Print "Sleeping..."
Sleep ms, 1 '' the "1" means Sleep can't be interrupted with a keystroke
Print "Awake!"
End

View file

@ -0,0 +1,7 @@
do
t = eval[input["Enter amount of time to sleep: ", "1 second"]]
while ! (t conforms time)
println["Sleeping..."]
sleep[t]
println["Awake!"]

13
Task/Sleep/Go/sleep.go Normal file
View file

@ -0,0 +1,13 @@
package main
import "time"
import "fmt"
func main() {
fmt.Print("Enter number of seconds to sleep: ")
var sec float64
fmt.Scanf("%f", &sec)
fmt.Print("Sleeping…")
time.Sleep(time.Duration(sec * float64(time.Second)))
fmt.Println("\nAwake!")
}

View file

@ -0,0 +1,5 @@
def sleepTest = {
println("Sleeping...")
sleep(it)
println("Awake!")
}

View file

@ -0,0 +1,12 @@
sleepTest(1000)
print '''
Hmmm. That was... less than satisfying.
How about this instead?
'''
Thread.start {
(0..5).each {
println it
sleep(1000)
}
}
sleepTest(5000)

View file

@ -0,0 +1,6 @@
import Control.Concurrent
main = do seconds <- readLn
putStrLn "Sleeping..."
threadDelay $ round $ seconds * 1000000
putStrLn "Awake!"

View file

@ -0,0 +1,4 @@
DLG(NameEdit = milliseconds, Button = "Go to sleep")
WRITE(StatusBar) "Sleeping ... "
SYSTEM(WAIT = milliseconds)
WRITE(Messagebox) "Awake!"

4
Task/Sleep/IDL/sleep.idl Normal file
View file

@ -0,0 +1,4 @@
read,i,prompt='Input sleep time in seconds: '
print,'Sleeping...'
wait,i ; in seconds, but accepts floats(/fractional) as input
print,'Awake!'

View file

@ -0,0 +1,12 @@
procedure main()
repeat {
writes("Enter number of seconds to sleep :")
s := reads()
if s = ( 0 < integer(s)) then break
}
write("\nSleeping for ",s," seconds.")
delay(1000 * s)
write("Awake!")
end

7
Task/Sleep/J/sleep-1.j Normal file
View file

@ -0,0 +1,7 @@
sleep =: 6!:3
sleeping=: monad define
smoutput 'Sleeping...'
sleep y
smoutput 'Awake!'
)

3
Task/Sleep/J/sleep-2.j Normal file
View file

@ -0,0 +1,3 @@
sleeping 0.500 NB. Sleep 500 milliseconds
Sleeping...
Awake!

View file

@ -0,0 +1,15 @@
import java.util.InputMismatchException;
import java.util.Scanner;
public class Sleep {
public static void main(final String[] args) throws InterruptedException {
try {
int ms = new Scanner(System.in).nextInt(); //Java's sleep method accepts milliseconds
System.out.println("Sleeping...");
Thread.sleep(ms);
System.out.println("Awake!");
} catch (InputMismatchException inputMismatchException) {
System.err.println("Exception: " + inputMismatchException);
}
}
}

View file

@ -0,0 +1,9 @@
<script>
setTimeout(function () {
document.write('Awake!')
}, prompt("Number of milliseconds to sleep"));
document.write('Sleeping... ');
</script>

7
Task/Sleep/Jq/sleep.jq Normal file
View file

@ -0,0 +1,7 @@
# Pseudosleep for at least the given number of $seconds (a number)
# and emit the actual number of seconds that have elapsed.
def sleep($seconds):
now
| . as $now
| until( . - $now >= $seconds; now)
| . - $now ;

View file

@ -0,0 +1,10 @@
/*
Sleep, in Jsish
*/
printf('Sleep time (in milliseconds)? ');
var ms = parseInt(console.input());
puts('Sleeping...');
sleep(ms);
puts('Awake!');

View file

@ -0,0 +1,5 @@
print("Please enter sleep duration in seconds: ")
input = int(readline(STDIN))
println("Sleeping...")
sleep(input)
println("Awake!")

View file

@ -0,0 +1,9 @@
// version 1.0.6
fun main(args: Array<String>) {
print("Enter number of milliseconds to sleep: ")
val ms = readLine()!!.toLong()
println("Sleeping...")
Thread.sleep(ms)
println("Awake!")
}

View file

@ -0,0 +1,4 @@
$ms = fn.long(fn.input())
fn.println(Sleeping...)
fn.sleep($ms)
fn.println(Awake!)

View file

@ -0,0 +1,3 @@
stdoutnl('Sleeping...')
sleep(5000) // Sleep 5 seconds
stdoutnl('Awake!')

View file

@ -0,0 +1,12 @@
make "Void "V0
make "Long "U4
make "kernel32_handle libload "kernel32.dll
to Sleep :dwMilliseconds
end
external "Sleep [ Void Sleep Long] :kernel32_handle
to millisleep :n
print [Sleeping...]
Sleep :n ; units: 1/1000th of a second
print [Awake.]
end

View file

@ -0,0 +1,4 @@
Input "Please input the number of milliseconds you would like to sleep. "; sleeptime
Print "Sleeping..."
CallDLL #kernel32, "Sleep", sleeptime As long, ret As void
Print "Awake!"

View file

@ -0,0 +1,5 @@
on doSleep (ms)
put "Sleeping..."
sleep(ms)
put "Awake!"
end

View file

@ -0,0 +1,5 @@
to sleep :n
print [Sleeping...]
wait :n ; units: 1/60th of a second
print [Awake.]
end

View file

@ -0,0 +1,10 @@
:- object(sleep).
:- public(how_long/1).
how_long(Seconds) :-
write('Sleeping ...'), nl,
thread_sleep(Seconds),
write('... awake!'), nl.
:- end_object.

View file

@ -0,0 +1,4 @@
| ?- sleep::how_long(5).
Sleeping ...
... awake!
yes

6
Task/Sleep/Lua/sleep.lua Normal file
View file

@ -0,0 +1,6 @@
local socket = require("socket")
io.write("Input a number of seconds to sleep: ")
local input = io.read("*number")
print("Sleeping")
socket.sleep(input)
print("Awake!")

View file

@ -0,0 +1,7 @@
Module CheckIt {
Input "Input a number of milliseconds to sleep:", N
Print "Sleeping..."
Wait N
Print "Awake"
}
CheckIt

View file

@ -0,0 +1,9 @@
function sleep()
time = input('How many seconds would you like me to sleep for? ');
assert(time > .01);
disp('Sleeping...');
pause(time);
disp('Awake!');
end

View file

@ -0,0 +1,5 @@
sleep := proc(secs)
print("Sleeping...");
Threads:-Sleep(secs);
print("Awake!");
end proc:

View file

@ -0,0 +1 @@
Sleep[seconds_] := (Print["Sleeping..."]; Pause[seconds]; Print["Awake!"];)

4
Task/Sleep/Min/sleep.min Normal file
View file

@ -0,0 +1,4 @@
"Enter number of milliseconds to sleep" ask int
"Sleeping..." puts!
sleep
"Awake!" puts!

View file

@ -0,0 +1,3 @@
10 PRINT "I'LL TELL YOU WHEN I BECOME AWAKE AGAIN..."
20 PAUSE 100
30 PRINT "NOW I'M AWAKE AGAIN."

View file

@ -0,0 +1,5 @@
time = int(input("time to sleep (ms): "))
println "Sleeping..."
sleep(time)
println "Awake!"

View file

@ -0,0 +1,14 @@
using System;
using System.Console;
using System.Threading.Thread; // this is where the Sleep() method comes from
module Zzzz
{
Main() : void
{
def nap_time = Int32.Parse(ReadLine());
WriteLine("Sleeping...");
Sleep(nap_time); // parameter is time in milliseconds
WriteLine("Awake!");
}
}

View file

@ -0,0 +1,37 @@
/* NetRexx */
options replace format comments java crossref symbols nobinary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method sleep(secs) public static binary
ms = (secs * 1000).format(null, 0) -- milliseconds, rounded to nearest integer
say 'Sleeping...'
do
Thread.sleep(ms)
catch ix = InterruptedException
say 'Sleep interrupted!'
ix.printStackTrace()
end
say 'Awake!'
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) public static
secs = -1
loop until \secs.datatype('N')
if secs > 0 then do
say 'Napping for' secs's'
say
sleep(secs)
end
say
say 'How many seconds do you want me to sleep? (enter something non-numeric to terminate)\-'
parse ask secs .
say
end
say
say 'Goodbye...'
say
return

View file

@ -0,0 +1,3 @@
(println "Sleeping..." )
(sleep 2000) ; Wait for 2 seconds
(println "Awake!")

7
Task/Sleep/Nim/sleep.nim Normal file
View file

@ -0,0 +1,7 @@
import os, strutils
echo "Enter how long I should sleep (in milliseconds):"
var timed = stdin.readLine.parseInt()
echo "Sleeping..."
sleep timed
echo "Awake!"

View file

@ -0,0 +1,5 @@
#load "unix.cma";;
let seconds = read_int ();;
print_endline "Sleeping...";;
Unix.sleep seconds;; (* number is integer in seconds *)
print_endline "Awake!";;

View file

@ -0,0 +1,7 @@
#load "unix.cma";;
#directory "+threads";;
#load "threads.cma";;
let seconds = read_float ();;
print_endline "Sleeping...";;
Thread.delay seconds;; (* number is in seconds ... but accepts fractions *)
print_endline "Awake!";;

View file

@ -0,0 +1,11 @@
bundle Default {
class Test {
function : Main(args : System.String[]) ~ Nil {
if(args->Size() = 1) {
"Sleeping..."->PrintLine();
Thread->Sleep(args[0]->ToInt());
"Awake!"->PrintLine();
};
}
}
}

View file

@ -0,0 +1,17 @@
#import <Foundation/Foundation.h>
int main()
{
@autoreleasepool {
NSTimeInterval sleeptime;
printf("wait time in seconds: ");
scanf("%f", &sleeptime);
NSLog(@"sleeping...");
[NSThread sleepForTimeInterval: sleeptime];
NSLog(@"awakening...");
}
return 0;
}

View file

@ -0,0 +1 @@
: sleepMilli(n) "Sleeping..." . n sleep "Awake!" println ;

View file

@ -0,0 +1,3 @@
Say time()
Call sysSleep 10 -- wait 10 seconds
Say time()

8
Task/Sleep/Oz/sleep.oz Normal file
View file

@ -0,0 +1,8 @@
declare
class TextFile from Open.file Open.text end
StdIn = {New TextFile init(name:stdin)}
WaitTime = {String.toInt {StdIn getS($)}}
in
{System.showInfo "Sleeping..."}
{Delay WaitTime} %% in milliseconds
{System.showInfo "Awake!"}

Some files were not shown because too many files have changed in this diff Show more