Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View 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

View 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"``");
}

View 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

View 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 + ')')

View file

@ -0,0 +1,4 @@
import rdstdin, strutils
let str = readLineFromStdin "Input a string: "
let num = parseInt(readLineFromStdin "Input a string: ")

View 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 ;

View file

@ -0,0 +1,2 @@
?prompt_string("Enter any string:")
?prompt_number("Enter the number 75000:",{75000,75000})

View 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

View file

@ -0,0 +1,2 @@
var s = read(String);
var i = read(Number); # auto-conversion to a number

View file

@ -0,0 +1,2 @@
var s = Sys.readln("Enter a string: ");
var i = Sys.readln("Enter a number: ").to_i;

View file

@ -0,0 +1,4 @@
print("Enter a string: ", terminator: "")
if let str = readLine() {
print(str)
}

View 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

View 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: \(.)")

View 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