Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
35
Task/User-input-Text/Axe/user-input-text.axe
Normal file
35
Task/User-input-Text/Axe/user-input-text.axe
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
Disp "String:"
|
||||
input→A
|
||||
length(A)→L
|
||||
|
||||
.Copy the string to a safe location
|
||||
Copy(A,L₁,L)
|
||||
|
||||
.Display the string
|
||||
Disp "You entered:",i
|
||||
For(I,0,L-1)
|
||||
Disp {L₁+I}►Char
|
||||
End
|
||||
Disp i
|
||||
|
||||
Disp "Integer:",i
|
||||
input→B
|
||||
length(B)→L
|
||||
|
||||
.Parse the string and convert to an integer
|
||||
0→C
|
||||
For(I,0,L-1)
|
||||
{B+I}-'0'→N
|
||||
If N>10
|
||||
.Error checking
|
||||
Disp "Not a number",i
|
||||
Return
|
||||
End
|
||||
C*10+N→C
|
||||
End
|
||||
|
||||
.Display and check the integer
|
||||
Disp "You entered:",i,C►Dec,i
|
||||
If C≠7500
|
||||
Disp "That isn't 7500"
|
||||
End
|
||||
8
Task/User-input-Text/Ceylon/user-input-text.ceylon
Normal file
8
Task/User-input-Text/Ceylon/user-input-text.ceylon
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
shared void run() {
|
||||
print("enter any text here");
|
||||
value text = process.readLine();
|
||||
print(text);
|
||||
print("enter the number 7500 here");
|
||||
value number = parseInteger(process.readLine() else "") else -1;
|
||||
print("``number == 7500 then number else "close enough"``");
|
||||
}
|
||||
11
Task/User-input-Text/FreeBASIC/user-input-text.freebasic
Normal file
11
Task/User-input-Text/FreeBASIC/user-input-text.freebasic
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Dim s As String
|
||||
Dim i AS Integer
|
||||
Input "Please enter a string : "; s
|
||||
Do
|
||||
Input "Please enter 75000 : "; i
|
||||
Loop Until i = 75000
|
||||
Print
|
||||
Print s, i
|
||||
Sleep
|
||||
31
Task/User-input-Text/Lasso/user-input-text.lasso
Normal file
31
Task/User-input-Text/Lasso/user-input-text.lasso
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/lasso9
|
||||
|
||||
define read_input(prompt::string) => {
|
||||
|
||||
local(string)
|
||||
|
||||
// display prompt
|
||||
stdout(#prompt)
|
||||
// the following bits wait until the terminal gives you back a line of input
|
||||
while(not #string or #string -> size == 0) => {
|
||||
#string = file_stdin -> readsomebytes(1024, 1000)
|
||||
}
|
||||
#string -> replace(bytes('\n'), bytes(''))
|
||||
|
||||
return #string -> asstring
|
||||
|
||||
}
|
||||
|
||||
local(
|
||||
string,
|
||||
number
|
||||
)
|
||||
|
||||
// get string
|
||||
#string = read_input('Enter the string: ')
|
||||
|
||||
// get number
|
||||
#number = integer(read_input('Enter the number: '))
|
||||
|
||||
// deliver the result
|
||||
stdoutnl(#string + ' (' + #string -> type + ') | ' + #number + ' (' + #number -> type + ')')
|
||||
4
Task/User-input-Text/Nim/user-input-text.nim
Normal file
4
Task/User-input-Text/Nim/user-input-text.nim
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import rdstdin, strutils
|
||||
|
||||
let str = readLineFromStdin "Input a string: "
|
||||
let num = parseInt(readLineFromStdin "Input a string: ")
|
||||
8
Task/User-input-Text/Oforth/user-input-text.oforth
Normal file
8
Task/User-input-Text/Oforth/user-input-text.oforth
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import: console
|
||||
|
||||
: testInput{
|
||||
| s n |
|
||||
System.Console askln ->s
|
||||
while (System.Console askln asInteger dup ->n isNull) [ "Not an integer" println ]
|
||||
|
||||
System.Out "Received : " << s << " and " << n << cr ;
|
||||
2
Task/User-input-Text/Phix/user-input-text.phix
Normal file
2
Task/User-input-Text/Phix/user-input-text.phix
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
?prompt_string("Enter any string:")
|
||||
?prompt_number("Enter the number 75000:",{75000,75000})
|
||||
4
Task/User-input-Text/Ring/user-input-text.ring
Normal file
4
Task/User-input-Text/Ring/user-input-text.ring
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
see "Enter a string : " give s
|
||||
see "Enter an integer : " give i
|
||||
see "String = " + s + nl
|
||||
see "Integer = " + i + nl
|
||||
2
Task/User-input-Text/Sidef/user-input-text-1.sidef
Normal file
2
Task/User-input-Text/Sidef/user-input-text-1.sidef
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var s = read(String);
|
||||
var i = read(Number); # auto-conversion to a number
|
||||
2
Task/User-input-Text/Sidef/user-input-text-2.sidef
Normal file
2
Task/User-input-Text/Sidef/user-input-text-2.sidef
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var s = Sys.readln("Enter a string: ");
|
||||
var i = Sys.readln("Enter a number: ").to_i;
|
||||
4
Task/User-input-Text/Swift/user-input-text.swift
Normal file
4
Task/User-input-Text/Swift/user-input-text.swift
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
print("Enter a string: ", terminator: "")
|
||||
if let str = readLine() {
|
||||
print(str)
|
||||
}
|
||||
14
Task/User-input-Text/Ursa/user-input-text.ursa
Normal file
14
Task/User-input-Text/Ursa/user-input-text.ursa
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#
|
||||
# user input
|
||||
#
|
||||
|
||||
# in ursa, the type of data expected must be specified
|
||||
decl string str
|
||||
decl int i
|
||||
|
||||
out "input a string: " console
|
||||
set str (in string console)
|
||||
out "input an int: " console
|
||||
set i (in int console)
|
||||
|
||||
out "you entered " str " and " i endl console
|
||||
8
Task/User-input-Text/jq/user-input-text-1.jq
Normal file
8
Task/User-input-Text/jq/user-input-text-1.jq
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
def read(int):
|
||||
null | until( . == int; "Expecting \(int)" | stderr | input);
|
||||
|
||||
def read_string:
|
||||
null | until( type == "string"; "Please enter a string" | stderr | input);
|
||||
|
||||
(read_string | "I see the string: \(.)"),
|
||||
(read(75000) | "I see the expected integer: \(.)")
|
||||
13
Task/User-input-Text/jq/user-input-text-2.jq
Normal file
13
Task/User-input-Text/jq/user-input-text-2.jq
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
$ jq -n -r -f User_input.jq
|
||||
"Please enter a string"
|
||||
1
|
||||
"Please enter a string"
|
||||
"ok"
|
||||
I see the string: ok
|
||||
"Expecting 75000"
|
||||
1
|
||||
"Expecting 75000"
|
||||
"ok"
|
||||
"Expecting 75000"
|
||||
75000
|
||||
I see the expected integer: 75000
|
||||
Loading…
Add table
Add a link
Reference in a new issue