all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
6
Task/Sleep/0DESCRIPTION
Normal file
6
Task/Sleep/0DESCRIPTION
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
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.
|
||||
2
Task/Sleep/1META.yaml
Normal file
2
Task/Sleep/1META.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
note: Basic language learning
|
||||
12
Task/Sleep/AWK/sleep.awk
Normal file
12
Task/Sleep/AWK/sleep.awk
Normal 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) {}
|
||||
}
|
||||
11
Task/Sleep/Ada/sleep.ada
Normal file
11
Task/Sleep/Ada/sleep.ada
Normal 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;
|
||||
4
Task/Sleep/AutoHotkey/sleep.ahk
Normal file
4
Task/Sleep/AutoHotkey/sleep.ahk
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
TrayTip, sleeping, sleeping
|
||||
sleep, 2000 ; 2 seconds
|
||||
TrayTip, awake, awake
|
||||
Msgbox, awake
|
||||
6
Task/Sleep/AutoIt/sleep.autoit
Normal file
6
Task/Sleep/AutoIt/sleep.autoit
Normal 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")
|
||||
4
Task/Sleep/BASIC/sleep-1.basic
Normal file
4
Task/Sleep/BASIC/sleep-1.basic
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
INPUT sec 'the SLEEP command takes seconds
|
||||
PRINT "Sleeping..."
|
||||
SLEEP sec
|
||||
PRINT "Awake!"
|
||||
5
Task/Sleep/BASIC/sleep-2.basic
Normal file
5
Task/Sleep/BASIC/sleep-2.basic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
10 REM s is the number of seconds
|
||||
20 LET s = 5
|
||||
30 PRINT "Sleeping"
|
||||
40 PAUSE s * 50
|
||||
50 PRINT "Awake"
|
||||
4
Task/Sleep/BBC-BASIC/sleep.bbc
Normal file
4
Task/Sleep/BBC-BASIC/sleep.bbc
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
INPUT "Enter the time to sleep in centiseconds: " sleep%
|
||||
PRINT "Sleeping..."
|
||||
WAIT sleep%
|
||||
PRINT "Awake!"
|
||||
6
Task/Sleep/Batch-File/sleep-1.bat
Normal file
6
Task/Sleep/Batch-File/sleep-1.bat
Normal 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!
|
||||
5
Task/Sleep/Batch-File/sleep-2.bat
Normal file
5
Task/Sleep/Batch-File/sleep-2.bat
Normal 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!
|
||||
5
Task/Sleep/Batch-File/sleep-3.bat
Normal file
5
Task/Sleep/Batch-File/sleep-3.bat
Normal 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!
|
||||
11
Task/Sleep/C++/sleep-1.cpp
Normal file
11
Task/Sleep/C++/sleep-1.cpp
Normal 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";
|
||||
}
|
||||
14
Task/Sleep/C++/sleep-2.cpp
Normal file
14
Task/Sleep/C++/sleep-2.cpp
Normal 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;
|
||||
}
|
||||
12
Task/Sleep/C/sleep.c
Normal file
12
Task/Sleep/C/sleep.c
Normal 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;
|
||||
}
|
||||
6
Task/Sleep/Clojure/sleep.clj
Normal file
6
Task/Sleep/Clojure/sleep.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(defn sleep [ms] ; time in milliseconds
|
||||
(println "Sleeping...")
|
||||
(Thread/sleep ms)
|
||||
(println "Awake!"))
|
||||
; call it
|
||||
(sleep 1000)
|
||||
7
Task/Sleep/Common-Lisp/sleep.lisp
Normal file
7
Task/Sleep/Common-Lisp/sleep.lisp
Normal 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
12
Task/Sleep/D/sleep.d
Normal 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!");
|
||||
}
|
||||
17
Task/Sleep/Delphi/sleep.delphi
Normal file
17
Task/Sleep/Delphi/sleep.delphi
Normal 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.
|
||||
7
Task/Sleep/E/sleep.e
Normal file
7
Task/Sleep/E/sleep.e
Normal 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
11
Task/Sleep/EGL/sleep.egl
Normal 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
|
||||
17
Task/Sleep/Eiffel/sleep.e
Normal file
17
Task/Sleep/Eiffel/sleep.e
Normal 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
|
||||
4
Task/Sleep/Erlang/sleep-1.erl
Normal file
4
Task/Sleep/Erlang/sleep-1.erl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
main() ->
|
||||
io:format("Sleeping...~n"),
|
||||
timer:sleep(1000), %% in milliseconds
|
||||
io:format("Awake!~n").
|
||||
6
Task/Sleep/Erlang/sleep-2.erl
Normal file
6
Task/Sleep/Erlang/sleep-2.erl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
main() ->
|
||||
io:format("Sleeping...~n"),
|
||||
receive
|
||||
after 1000 -> ok %% in milliseconds
|
||||
end,
|
||||
io:format("Awake!~n").
|
||||
7
Task/Sleep/Factor/sleep.factor
Normal file
7
Task/Sleep/Factor/sleep.factor
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
USING: calendar io math.parser threads ;
|
||||
|
||||
: read-sleep ( -- )
|
||||
readln string>number seconds
|
||||
"Sleeping..." print
|
||||
sleep
|
||||
"Awake!" print ;
|
||||
21
Task/Sleep/Fantom/sleep.fantom
Normal file
21
Task/Sleep/Fantom/sleep.fantom
Normal 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
4
Task/Sleep/Forth/sleep.fth
Normal file
4
Task/Sleep/Forth/sleep.fth
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
: sleep ( ms -- )
|
||||
." Sleeping..."
|
||||
ms
|
||||
." awake." cr ;
|
||||
18
Task/Sleep/Fortran/sleep.f
Normal file
18
Task/Sleep/Fortran/sleep.f
Normal 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
|
||||
7
Task/Sleep/Frink/sleep.frink
Normal file
7
Task/Sleep/Frink/sleep.frink
Normal 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
13
Task/Sleep/Go/sleep.go
Normal 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!")
|
||||
}
|
||||
5
Task/Sleep/Groovy/sleep-1.groovy
Normal file
5
Task/Sleep/Groovy/sleep-1.groovy
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
def sleepTest = {
|
||||
println("Sleeping...")
|
||||
sleep(it)
|
||||
println("Awake!")
|
||||
}
|
||||
12
Task/Sleep/Groovy/sleep-2.groovy
Normal file
12
Task/Sleep/Groovy/sleep-2.groovy
Normal 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)
|
||||
6
Task/Sleep/Haskell/sleep.hs
Normal file
6
Task/Sleep/Haskell/sleep.hs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import Control.Concurrent
|
||||
|
||||
main = do seconds <- readLn
|
||||
putStrLn "Sleeping..."
|
||||
threadDelay $ round $ seconds * 1000000
|
||||
putStrLn "Awake!"
|
||||
4
Task/Sleep/HicEst/sleep.hicest
Normal file
4
Task/Sleep/HicEst/sleep.hicest
Normal 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
4
Task/Sleep/IDL/sleep.idl
Normal 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!'
|
||||
12
Task/Sleep/Icon/sleep.icon
Normal file
12
Task/Sleep/Icon/sleep.icon
Normal 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
7
Task/Sleep/J/sleep-1.j
Normal 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
3
Task/Sleep/J/sleep-2.j
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
sleeping 0.500 NB. Sleep 500 milliseconds
|
||||
Sleeping...
|
||||
Awake!
|
||||
15
Task/Sleep/Java/sleep.java
Normal file
15
Task/Sleep/Java/sleep.java
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Task/Sleep/JavaScript/sleep.js
Normal file
9
Task/Sleep/JavaScript/sleep.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<script>
|
||||
|
||||
setTimeout(function () {
|
||||
document.write('Awake!')
|
||||
}, prompt("Number of milliseconds to sleep"));
|
||||
|
||||
document.write('Sleeping... ');
|
||||
|
||||
</script>
|
||||
4
Task/Sleep/Liberty-BASIC/sleep.liberty
Normal file
4
Task/Sleep/Liberty-BASIC/sleep.liberty
Normal 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!"
|
||||
5
Task/Sleep/Logo/sleep.logo
Normal file
5
Task/Sleep/Logo/sleep.logo
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
to sleep :n
|
||||
print [Sleeping...]
|
||||
wait :n ; units: 1/60th of a second
|
||||
print [Awake.]
|
||||
end
|
||||
9
Task/Sleep/MATLAB/sleep.m
Normal file
9
Task/Sleep/MATLAB/sleep.m
Normal 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
|
||||
1
Task/Sleep/Mathematica/sleep.math
Normal file
1
Task/Sleep/Mathematica/sleep.math
Normal file
|
|
@ -0,0 +1 @@
|
|||
Sleep[seconds_] := (Print["Sleeping..."]; Pause[seconds]; Print["Awake!"];)
|
||||
37
Task/Sleep/NetRexx/sleep.netrexx
Normal file
37
Task/Sleep/NetRexx/sleep.netrexx
Normal 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
|
||||
3
Task/Sleep/NewLISP/sleep.newlisp
Normal file
3
Task/Sleep/NewLISP/sleep.newlisp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(println "Sleeping..." )
|
||||
(sleep 2000) ; Wait for 2 seconds
|
||||
(println "Awake!")
|
||||
7
Task/Sleep/Nimrod/sleep.nimrod
Normal file
7
Task/Sleep/Nimrod/sleep.nimrod
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import os, strutils
|
||||
|
||||
echo("Enter how long I should sleep (in milliseconds):")
|
||||
var timed = parseInt(readLine(stdin).string)
|
||||
echo("Sleeping...")
|
||||
sleep(timed)
|
||||
echo("Awake!")
|
||||
5
Task/Sleep/OCaml/sleep-1.ocaml
Normal file
5
Task/Sleep/OCaml/sleep-1.ocaml
Normal 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!";;
|
||||
7
Task/Sleep/OCaml/sleep-2.ocaml
Normal file
7
Task/Sleep/OCaml/sleep-2.ocaml
Normal 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!";;
|
||||
11
Task/Sleep/Objeck/sleep.objeck
Normal file
11
Task/Sleep/Objeck/sleep.objeck
Normal 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();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Task/Sleep/Objective-C/sleep.m
Normal file
17
Task/Sleep/Objective-C/sleep.m
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSTimeInterval sleeptime;
|
||||
|
||||
printf("wait time in seconds: ");
|
||||
scanf("%f", &sleeptime);
|
||||
|
||||
NSLog(@"sleeping...");
|
||||
[NSThread sleepForTimeInterval: sleeptime];
|
||||
NSLog(@"awakening...");
|
||||
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
8
Task/Sleep/Oz/sleep.oz
Normal file
8
Task/Sleep/Oz/sleep.oz
Normal 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!"}
|
||||
7
Task/Sleep/PARI-GP/sleep-1.pari
Normal file
7
Task/Sleep/PARI-GP/sleep-1.pari
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
sleep(ms)={
|
||||
print("Sleeping...");
|
||||
while((ms-=gettime()) > 0,);
|
||||
print("Awake!")
|
||||
};
|
||||
|
||||
sleep(input())
|
||||
8
Task/Sleep/PARI-GP/sleep-2.pari
Normal file
8
Task/Sleep/PARI-GP/sleep-2.pari
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
sleep(s)={
|
||||
print("Sleeping...");
|
||||
alarm(s);
|
||||
trap(alarmer,,while(1,));
|
||||
print("Awake!")
|
||||
};
|
||||
|
||||
sleep(input())
|
||||
4
Task/Sleep/PHP/sleep-1.php
Normal file
4
Task/Sleep/PHP/sleep-1.php
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$seconds = 42;
|
||||
echo "Sleeping...\n";
|
||||
sleep($seconds); # number is integer in seconds
|
||||
echo "Awake!\n";
|
||||
4
Task/Sleep/PHP/sleep-2.php
Normal file
4
Task/Sleep/PHP/sleep-2.php
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$microseconds = 42000000;
|
||||
echo "Sleeping...\n";
|
||||
usleep($microseconds); # number is integer in microseconds
|
||||
echo "Awake!\n";
|
||||
4
Task/Sleep/PHP/sleep-3.php
Normal file
4
Task/Sleep/PHP/sleep-3.php
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$nanoseconds = 42000000000;
|
||||
echo "Sleeping...\n";
|
||||
time_nanosleep($seconds, $nanoseconds); # first arg in seconds plus second arg in nanoseconds
|
||||
echo "Awake!\n";
|
||||
3
Task/Sleep/PL-I/sleep.pli
Normal file
3
Task/Sleep/PL-I/sleep.pli
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
put ('sleeping');
|
||||
delay (2000); /* wait for 2 seconds (=2000 milliseconds). */
|
||||
put ('awake');
|
||||
4
Task/Sleep/Perl-6/sleep.pl6
Normal file
4
Task/Sleep/Perl-6/sleep.pl6
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
my $sec = prompt("Sleep for how many microfortnights? ") * 1.2096;
|
||||
say "Sleeping...";
|
||||
sleep $sec;
|
||||
say "Awake!";
|
||||
4
Task/Sleep/Perl/sleep-1.pl
Normal file
4
Task/Sleep/Perl/sleep-1.pl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$seconds = <>;
|
||||
print "Sleeping...\n";
|
||||
sleep $seconds; # number is in seconds
|
||||
print "Awake!\n";
|
||||
11
Task/Sleep/Perl/sleep-2.pl
Normal file
11
Task/Sleep/Perl/sleep-2.pl
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
use Time::HiRes qw( usleep nanosleep );
|
||||
|
||||
$microseconds = <>;
|
||||
print "Sleeping...\n";
|
||||
usleep $microseconds;
|
||||
print "Awake!\n";
|
||||
|
||||
$nanoseconds = <>;
|
||||
print "Sleeping...\n";
|
||||
nanosleep $nanoseconds;
|
||||
print "Awake!\n";
|
||||
3
Task/Sleep/PicoLisp/sleep-1.l
Normal file
3
Task/Sleep/PicoLisp/sleep-1.l
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(prinl "Sleeping..." )
|
||||
(wait 2000) # Wait for 2 seconds
|
||||
(prinl "Awake!")
|
||||
3
Task/Sleep/PicoLisp/sleep-2.l
Normal file
3
Task/Sleep/PicoLisp/sleep-2.l
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(prinl "Sleeping..." )
|
||||
(call 'sleep 2) # Wait for 2 seconds
|
||||
(prinl "Awake!")
|
||||
4
Task/Sleep/PowerShell/sleep.psh
Normal file
4
Task/Sleep/PowerShell/sleep.psh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$d = [int] (Read-Host Duration in seconds)
|
||||
Write-Host Sleeping ...
|
||||
Start-Sleep $d
|
||||
Write-Host Awake!
|
||||
4
Task/Sleep/Prolog/sleep.pro
Normal file
4
Task/Sleep/Prolog/sleep.pro
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
rosetta_sleep(Time) :-
|
||||
writeln('Sleeping...'),
|
||||
sleep(Time),
|
||||
writeln('Awake!').
|
||||
4
Task/Sleep/Protium/sleep-1.protium
Normal file
4
Task/Sleep/Protium/sleep-1.protium
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<@ SAYLIT>Number of seconds: </@><@ GETVAR>secs</@>
|
||||
<@ SAYLIT>Sleeping</@>
|
||||
<@ ACTPAUVAR>secs</@>
|
||||
<@ SAYLIT>Awake</@>
|
||||
4
Task/Sleep/Protium/sleep-2.protium
Normal file
4
Task/Sleep/Protium/sleep-2.protium
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<# MontrezLittéralement>Number of seconds: </#><# PrenezUneValeurVariable>secs</#>
|
||||
<# MontrezLittéralement>Sleeping</#>
|
||||
<# AgissezFaireUnePauseVariable>secs</#>
|
||||
<# MontrezLittéralement>Awake</#>
|
||||
4
Task/Sleep/Protium/sleep-3.protium
Normal file
4
Task/Sleep/Protium/sleep-3.protium
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<@ 显示_字串_>Number of seconds: </@><@ 获取_变量_>secs</@>
|
||||
<@ 显示_字串_>Sleeping</@>
|
||||
<@ 运行_暂停动变量_>secs</@>
|
||||
<@ 显示_字串_>Awake</@>
|
||||
11
Task/Sleep/PureBasic/sleep.purebasic
Normal file
11
Task/Sleep/PureBasic/sleep.purebasic
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
If OpenConsole()
|
||||
|
||||
Print("Enter a time(milliseconds) to sleep: ")
|
||||
x.i = Val(Input())
|
||||
PrintN("Sleeping...")
|
||||
Delay(x) ;in milliseconds
|
||||
PrintN("Awake!")
|
||||
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit")
|
||||
Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
6
Task/Sleep/Python/sleep.py
Normal file
6
Task/Sleep/Python/sleep.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import time
|
||||
|
||||
seconds = float(raw_input())
|
||||
print "Sleeping..."
|
||||
time.sleep(seconds) # number is in seconds ... but accepts fractions
|
||||
print "Awake!"
|
||||
9
Task/Sleep/R/sleep.r
Normal file
9
Task/Sleep/R/sleep.r
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
sleep <- function(time=1)
|
||||
{
|
||||
message("Sleeping...")
|
||||
flush.console()
|
||||
Sys.sleep(time)
|
||||
message("Awake!")
|
||||
}
|
||||
|
||||
sleep()
|
||||
11
Task/Sleep/REBOL/sleep.rebol
Normal file
11
Task/Sleep/REBOL/sleep.rebol
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
REBOL [
|
||||
Title: "Sleep Main Thread"
|
||||
Date: 2009-12-15
|
||||
Author: oofoe
|
||||
URL: http://rosettacode.org/wiki/Sleep_the_Main_Thread
|
||||
]
|
||||
|
||||
naptime: to-integer ask "Please enter sleep time in seconds: "
|
||||
print "Sleeping..."
|
||||
wait naptime
|
||||
print "Awake!"
|
||||
6
Task/Sleep/REXX/sleep.rexx
Normal file
6
Task/Sleep/REXX/sleep.rexx
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/*REXX program to sleep x seconds (base in the argument). */
|
||||
parse arg secs . /*get a (possible) argument. */
|
||||
secs=word(secs 0,1) /*if not present, assume 0 (zero)*/
|
||||
say 'Sleeping' secs "seconds." /*tell 'em what's happening. */
|
||||
call delay(secs) /*snooze. Hopefully, a short nap*/
|
||||
say 'Awake!' /*and tell 'em we're running. */
|
||||
7
Task/Sleep/Racket/sleep.rkt
Normal file
7
Task/Sleep/Racket/sleep.rkt
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#lang racket
|
||||
(displayln "Enter a time (in seconds): ")
|
||||
(define time (read))
|
||||
(when (number? time)
|
||||
(displayln "Sleeping...")
|
||||
(sleep time)
|
||||
(displayln "Awake!"))
|
||||
6
Task/Sleep/Retro/sleep.retro
Normal file
6
Task/Sleep/Retro/sleep.retro
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
: sleep ( n- )
|
||||
[ time [ time over - 1 > ] until drop ] times ;
|
||||
: test
|
||||
"\nTime to sleep (in seconds): " puts getToken toNumber
|
||||
"\nSleeping..." sleep
|
||||
"\nAwake!\n" ;
|
||||
5
Task/Sleep/Ruby/sleep.rb
Normal file
5
Task/Sleep/Ruby/sleep.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
seconds = gets.to_f
|
||||
puts "Sleeping..."
|
||||
sleep(seconds) # number is in seconds ... but accepts fractions
|
||||
# Minimum resolution is system dependent.
|
||||
puts "Awake!"
|
||||
9
Task/Sleep/Scala/sleep.scala
Normal file
9
Task/Sleep/Scala/sleep.scala
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import java.util.Scanner
|
||||
|
||||
object Sleeper extends Application {
|
||||
val input = new Scanner(System.in)
|
||||
val ms = input.nextInt
|
||||
System.out.println("Sleeping...")
|
||||
Thread.sleep(ms)
|
||||
System.out.println("Awake!")
|
||||
}
|
||||
11
Task/Sleep/Scheme/sleep.ss
Normal file
11
Task/Sleep/Scheme/sleep.ss
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(use format)
|
||||
(use srfi-18)
|
||||
|
||||
(format #t "Enter a time (in seconds): ")
|
||||
(let ((time (read))) ; converts input to a number, if possible
|
||||
(if (number? time)
|
||||
(begin
|
||||
(format #t "Sleeping...~&")
|
||||
(thread-sleep! time)
|
||||
(format #t "Awake!~&"))
|
||||
(format #t "You must enter a number~&")))
|
||||
13
Task/Sleep/Seed7/sleep.seed7
Normal file
13
Task/Sleep/Seed7/sleep.seed7
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "duration.s7i";
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var integer: secondsToSleep is 0;
|
||||
begin
|
||||
write("Enter number of seconds to sleep: ");
|
||||
readln(secondsToSleep);
|
||||
writeln("Sleeping...");
|
||||
wait(secondsToSleep . SECONDS);
|
||||
writeln("Awake!");
|
||||
end func;
|
||||
4
Task/Sleep/Smalltalk/sleep-1.st
Normal file
4
Task/Sleep/Smalltalk/sleep-1.st
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
t := (FillInTheBlankMorph request: 'Enter time in seconds') asNumber.
|
||||
Transcript show: 'Sleeping...'.
|
||||
(Delay forSeconds: t) wait.
|
||||
Transcript show: 'Awake!'.
|
||||
4
Task/Sleep/Smalltalk/sleep-2.st
Normal file
4
Task/Sleep/Smalltalk/sleep-2.st
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
t := (Dialog request: 'Enter time in seconds') asNumber.
|
||||
Transcript show: 'Sleeping...'.
|
||||
(Delay forSeconds: t) wait.
|
||||
Transcript show: 'Awake!'.
|
||||
8
Task/Sleep/Standard-ML/sleep.ml
Normal file
8
Task/Sleep/Standard-ML/sleep.ml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(TextIO.print "input a number of seconds please: ";
|
||||
let val seconds = valOf (Int.fromString (valOf (TextIO.inputLine TextIO.stdIn))) in
|
||||
TextIO.print "Sleeping...\n";
|
||||
OS.Process.sleep (Time.fromReal seconds); (* it takes a Time.time data structure as arg,
|
||||
but in my implementation it seems to round down to the nearest second.
|
||||
I dunno why; it doesn't say anything about this in the documentation *)
|
||||
TextIO.print "Awake!\n"
|
||||
end)
|
||||
6
Task/Sleep/Suneido/sleep.suneido
Normal file
6
Task/Sleep/Suneido/sleep.suneido
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
function (time)
|
||||
{
|
||||
Print("Sleeping...")
|
||||
Sleep(time) // time is in milliseconds
|
||||
Print("Awake!")
|
||||
}
|
||||
5
Task/Sleep/TUSCRIPT/sleep.tuscript
Normal file
5
Task/Sleep/TUSCRIPT/sleep.tuscript
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
$$ MODE TUSCRIPT
|
||||
secondsrange=2
|
||||
PRINT "Sleeping ",secondsrange," seconds "
|
||||
WAIT #secondsrange
|
||||
PRINT "Awake after Naping ",secondsrange, " seconds"
|
||||
6
Task/Sleep/Tcl/sleep-1.tcl
Normal file
6
Task/Sleep/Tcl/sleep-1.tcl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
puts -nonewline "Enter a number of milliseconds to sleep: "
|
||||
flush stdout
|
||||
set millis [gets stdin]
|
||||
puts Sleeping...
|
||||
after $millis
|
||||
puts Awake!
|
||||
8
Task/Sleep/Tcl/sleep-2.tcl
Normal file
8
Task/Sleep/Tcl/sleep-2.tcl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
puts -nonewline "Enter a number of milliseconds to sleep: "
|
||||
flush stdout
|
||||
set millis [gets stdin]
|
||||
set ::wakupflag 0
|
||||
puts Sleeping...
|
||||
after $millis set ::wakeupflag 1
|
||||
vwait ::wakeupflag
|
||||
puts Awake!
|
||||
5
Task/Sleep/UNIX-Shell/sleep.sh
Normal file
5
Task/Sleep/UNIX-Shell/sleep.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
printf "Enter a time in seconds to sleep: "
|
||||
read seconds
|
||||
echo "Sleeping..."
|
||||
sleep "$seconds"
|
||||
echo "Awake!"
|
||||
4
Task/Sleep/VBScript/sleep.vbscript
Normal file
4
Task/Sleep/VBScript/sleep.vbscript
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
iSeconds=InputBox("Enter a time in seconds to sleep: ","Sleep Example for RosettaCode.org")
|
||||
WScript.Echo "Sleeping..."
|
||||
WScript.Sleep iSeconds*1000 'Sleep is done in Milli-Seconds
|
||||
WScript.Echo "Awake!"
|
||||
4
Task/Sleep/Vedit-macro-language/sleep.vedit
Normal file
4
Task/Sleep/Vedit-macro-language/sleep.vedit
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#1 = Get_Num("Sleep time in 1/10 seconds: ")
|
||||
Message("Sleeping...\n")
|
||||
Sleep(#1)
|
||||
Message("Awake!\n")
|
||||
Loading…
Add table
Add a link
Reference in a new issue